Skip to content

Instantly share code, notes, and snippets.

@moro
Created August 12, 2009 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save moro/166394 to your computer and use it in GitHub Desktop.
Save moro/166394 to your computer and use it in GitHub Desktop.
Array.class_eval do
def to_proc
first, *rest = self
Proc.new{|o| o.send(first, *rest) }
end
end
# p (1..10).map{|i|i.divmod(2)}
p (1..10).map(&[:divmod,2])
content = "Hello World"
File.open("/tmp/foobar.txt", "w", &[:puts, content])
puts File.read("/tmp/foobar.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment