Contents

Roo

File.read_lines

Returns a new Array object where each element is a line (as Text) from this file. The method automatically closes the file when done. If this File object is not valid then this getter returns Nothing.

# Assume the file `heroes.txt` contains the following lines:
# Iron Man
# Spider-Man
# Hulk
var f = File("/Users/garry/Desktop/heroes.txt")
var heroes = f.read_lines
print(heroes) # ["Iron Man", "Spider-Man", "Hulk"]