Skip to content

Instantly share code, notes, and snippets.

@bnorton
Last active August 29, 2015 14:02
Show Gist options
  • Save bnorton/975a716d3833758028e0 to your computer and use it in GitHub Desktop.
Save bnorton/975a716d3833758028e0 to your computer and use it in GitHub Desktop.
Convert an array to a proc that applies its members in sequence to the given item
class Array
def to_proc
->(item) do
self.each do|meth|
item = item.send meth
end
item
end
end
end
@bnorton
Copy link
Author

bnorton commented Jun 10, 2014

Simple Example:

[1,2,3].map(&[:to_f, :to_s])
  #=> ["1.0", "2.0", "3.0"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment