Read entire file

Reading an entire file as a string, can be achieved with the FileHandle.slurp() method, as illustrated bellow:

var file = File(__FILE__)
var content = file.open_r.slurp
print content

Starting with version 2.30, File.read() can do the same:

var file = File(__FILE__)
var content = file.read(:utf8)
print content