Currying

  • + 0 comments

    Much better explaination here:

    https://www.rubydoc.info/stdlib/core/Method:curry

    Returns a curried proc based on the method. When the proc is called with a number of arguments that is lower than the method's arity, then another curried proc is returned. Only when enough arguments have been supplied to satisfy the method signature, will the method actually be called.

    The optional arity argument should be supplied when currying methods with variable arguments to determine how many arguments are needed before the method is called.

    def foo(a,b,c) [a, b, c] end

    proc = self.method(:foo).curry proc2 = proc.call(1, 2) #=> # proc2.call(3) #=> [1,2,3]