|
|
|
|
|
by pmontra
1478 days ago
|
|
Or, in a different language open("file", "r").readlines.
map{|line| line.strip}.
filter{|line| line != ""}
or some smarter but less readable ways.I prefer the left-to-right transformations style to Python's list comprehension and inside-to-outside function composition. The reason is that it reminds me of how data flow into *nix pipelines. I spent decades working with them and I've been working with Ruby for the last half of that time. With Python in the last quarter of my career. It's a matter of choices and preferences of the original designed of the language. Both ways work. |
|