Created
October 21, 2011 10:29
-
-
Save moro/1303529 to your computer and use it in GitHub Desktop.
Symbol#<<
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Symbol | |
def <<(args) | |
lambda {|x| x.send(self, *args) } | |
end | |
end | |
p [{:a => 1}].find(&:key? << :a) # => {:a => 1} | |
p [{:a => 1}].find(&:key? << :b) # => nil | |
p [["abc", "efg"], ["foo", "bar"]].map(&:join << "-") # => ["abc-efg", "foo-bar"] | |
p ["abc", "efg", "foo", "bar"].map(&:sub << ["a", "A"]) # => ["Abc", "efg", "foo", "bAr"] |
ああ、自分は { |x| x... } とスペースを入れる派だからだ!
->x { x.... } はけっこうボーダーラインww すんません個人的感覚の話でww
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{|x|x....} はなんかダブリ感があるんですが ->x{x...} は意外とそうでもないなと思った。なぜだろう