How can I chomp every line in an array at once?

HandyGandy picture HandyGandy · Sep 20, 2010 · Viewed 8.4k times · Source

In the interest of writing cleaner code...

IO.popen("Generate a list of files").readlines.each{ |line|
   chomped_line = line.chomp
   # ...
}

Answer

buru picture buru · Sep 20, 2010
IO.popen("Generate a list of files").readlines.map(&:chomp)