Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby get line from a file

# open the file
File.open('foo.txt') do |file|
  # iterate over each line
  file.each_line do |line|
    puts line
  end
end
# since we passed a block, the file is automatically closed after `end`
 
PREVIOUS NEXT
Tagged: #ruby #line #file
ADD COMMENT
Topic
Name
3+4 =