RubyとPythonの流れる方向の違い
irb(main):021:0> s = "123 456 789" => "123 456 789" irb(main):022:0> s.scan(/\d+/) => ["123", "456", "789"] irb(main):024:0> s.scan(/\d+/).map{|x| x.to_i + 1} => [124, 457, 790]
>>> s = "123 456 789" >>> import re >>> re.findall(r"\d+", s) ['123', '456', '789'] >>> map(lambda x: int(x) + 1, re.findall(r"\d+", s)) [124, 457, 790]
右に流れていくRubyがちょっとうらやましい。