3 ms·
I am a scala dev but for scripts I use ruby. With pry, I have a great REPL, and ruby has no problem with those filter chains. [1] pry(main)> `ls` => "READ
by anko 9y ago
I am a scala dev but for scripts I use ruby. With pry, I have a great REPL, and ruby has no problem with those filter chains.
[1] pry(main)> `ls`
=> "README.md\n" + "_build\n" + "config\n" + "lib\n" + "mix.exs\n" + "test\n"
[2] pry(main)> `ls`.split
=> ["README.md", "_build", "config", "lib", "mix.exs", "test"]
[3] pry(main)> `ls`.split.map(&:upcase)
=> ["README.MD", "_BUILD", "CONFIG", "LIB", "MIX.EXS", "TEST"]
[4] pry(main)> `ls`.split.map(&:upcase).select { |x| x.match(/E/) }
=> ["README.MD", "MIX.EXS", "TEST"]