Created
February 28, 2010 23:37
-
-
Save chrislloyd/317921 to your computer and use it in GitHub Desktop.
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
# Symbol to Proc is a mutha' fucking dirty hack. It brings the indirection | |
# that we hated from Pearl to Ruby. How it made it into core I don't know. | |
# Anyway, rather than bitch and moan too much, here is an alternative method | |
# which is much more expressive and has the same number of characters. The | |
# name pick comes from Rebol, though it functions more like select there. | |
module Enumerable | |
def pick(meth) | |
map {|o| o.send(meth.to_sym)} | |
end | |
end | |
puts %W( d e a t h _ t o _ s y m _ t o _ p r o c).pick(:upcase).join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment