View Problem

Write a string to a file

DiskEdit
ruby
File.new("a_file", "w") << "some text"
ExpandDiskEdit
cpp C++/CLI .NET 2.0
IO::StreamWriter^ stream;

try
{
stream = gcnew IO::StreamWriter("test.txt", false);
stream->WriteLine("This line overwites file contents!");
}
ExpandDiskEdit
fantom
File(`out.txt`).out.writeChars("some text").flush
ExpandDiskEdit
erlang
Line = "This line overwites file contents!\n",
{ok, IODevice} = file:open("test.txt", [write]), file:write(IODevice, Line), file:close(IODevice).

Submit a new solution for ruby, cpp, fantom, or erlang
There are 15 other solutions in additional languages (clojure, csharp, fsharp, groovy ...)