Skip to content

Instantly share code, notes, and snippets.

@nicholasjhenry
Last active December 31, 2015 07:39
Show Gist options
  • Save nicholasjhenry/7955658 to your computer and use it in GitHub Desktop.
Save nicholasjhenry/7955658 to your computer and use it in GitHub Desktop.
Make a service class support currying, uh partial application?
module Curryable
def curry(arity=nil)
method(:call).to_proc.curry(arity)
end
end
class Foo
include Curryable
def call(x, y, z)
x + y + z
end
end
f = Foo.new
ff = f.curry.(2, 3) # or f.curry[2, 3]
ff.(4) # or ff[4] => 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment