collect the lines together : each line « File Directory « Ruby
- Ruby
- File Directory
- each line
collect the lines together
text=''
line_count = 0
File.open("text.txt").each do |line|
line_count += 1
text << line
end
puts "#{line_count} lines"
Related examples in the same category