Write entire file: Difference between revisions

Added Wren
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(Added Wren)
Line 870:
End Module
</lang>
 
=={{header|Wren}}==
The easiest way to overwrite a file in Wren is to 'create' it again which truncates the existing contents.
<lang ecmascript>import "io" for File
 
// create a text file
File.create("hello.txt") { |file|
file.writeBytes("hello")
}
 
// check it worked
System.print(File.read("hello.txt"))
 
// overwrite it by 'creating' the file again
File.create("hello.txt") {|file|
file.writeBytes("goodbye")
}
 
// check it worked
System.print(File.read("hello.txt"))</lang>
 
{{out}}
<pre>
hello
goodbye
</pre>
 
=={{header|XLISP}}==
9,482

edits