collect the lines together : each line « File Directory « Ruby






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

1.Text file line counter