Skip to content

Instantly share code, notes, and snippets.

@cutalion
Last active November 22, 2016 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cutalion/17c91699ad00457bf44f8b22c4c54ab9 to your computer and use it in GitHub Desktop.
Save cutalion/17c91699ad00457bf44f8b22c4c54ab9 to your computer and use it in GitHub Desktop.
class SuperCurry
def call(a, b)
puts "#{a} + #{b} = #{a + b}"
end
def curry(*args)
arity = method(:call).arity
curried_args = args
if curried_args.size == arity
call(*curried_args)
else
-> (*args) { curry *(curried_args + args) }
end
end
end
s = SuperCurry.new
c = s.curry
c.call(1).call(2) #=> 1 + 2 = 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment