標記のとおり、死ぬみたいです。
crankharder
I’m curious to know what the rational is behind this?
rohit
You can now use tap.
正論過ぎて返す言葉もありませんね。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | require "rubygems" require "active_support" a1 = returning [] do |ary| ary << 'hoge' ary << 'fuga' end a2 = [].tap do |ary| ary << 'hoge' ary << 'fuga' end require "spec" a1.should == a2 #=> true |
確かに、タイピング量的にも、tapの方が少なくなりますね。でも、1.8.6みたいにtapのバックポートが無い場合とか、あとreturningを使いまくってる場合は…。
そもそもtapもreturningも4行ぐらいで実装できるので、以下のような config/initializers/returning_strikes_back.rb を作成すれば互換性を確保できるんじゃあないでしょうか。あまり薦めませんが。。
1 2 3 4 5 6 7 8 9 10 | module ReturningStrikesBack def returning(value) yield(value) value end end class Object include ReturningStrikesBack end |




