Skip to content

Instantly share code, notes, and snippets.

@chrislloyd
Created February 28, 2010 23:37
Show Gist options
  • Save chrislloyd/317921 to your computer and use it in GitHub Desktop.
Save chrislloyd/317921 to your computer and use it in GitHub Desktop.
# 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