Kuripai

Some basic ruby

Some of the stuff that makes me love ruby

Read a file

File.read('file.txt')

Read a file line by line

array_of_lines = File.readlines('file.txt')

although I’d probably use it more like this:

File.readlines('file.txt').each {|l| puts line }
blog comments powered by Disqus