Created
July 4, 2013 17:04
-
-
Save enil/5929140 to your computer and use it in GitHub Desktop.
The way arrays are used as an variable argument list, *unless* the arity of a proc is 1 is a clusterfuck.
I think this is a safe way to fix a proc so that sending an array to the proc always treats the array
as an argument list.
`BasicObject.instance_exec` doesn't seem to use `Proc.call`, it has to be dealt with separately.
This file contains 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 Proc | |
def unfuck! | |
class << self | |
def call(*params) | |
if arity == 1 && params.first.is_a?(Array) | |
super(params.first.first) | |
else | |
super | |
end | |
end | |
end | |
self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It doesn't seem like
yield
usesProc.call
either, to yield to an unfucked proc you have to do something like this: