Read entire file: Difference between revisions

(Added Odin variant)
Line 2,029:
 
=={{header|Swift}}==
{{works with|Swift|1}}
 
<syntaxhighlight lang="swift">import Foundation
 
Line 2,035 ⟶ 2,037:
println(string) // print contents of file
}</syntaxhighlight>
 
{{works with|Swift|5}}
<syntaxhighlight lang="swift">import Foundation
 
let path = "input.txt"
do
{
let string = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
print(string) // print contents of file
}
catch
{
print("error occured: \(error)")
}
</syntaxhighlight>
 
=={{header|Tcl}}==
19

edits