Curry should know how far the arch went by, right?
:<.to_proc.arity
Negative values from arityare confusing, but basically mean "a variable number of arguments" anyway.
Compare with:
less_than = lambda {|a, b| a < b}
less_than.arity
-, , , #curry.
less_than.curry[9][8] # => false, no problem!
#to_proc , , , , . , < ruby, , , , # to_proc - , , args , proc .
C , MRI, , # to_proc proc . # to_proc, , . , , , :
hello_proc = :hello.to_proc
class SomeClass
def hello(name = nil)
puts "Hello, #{name}!"
end
end
obj = SomeClass.new
obj.hello
obj.hello("jrochkind")
obj.hello("jrochkind", "another")
hello_proc.call(obj)
hello_proc.call(obj, "jrochkind")
hello_proc.call(obj, "jrochkind", "another")
hello_proc.call("Some string")
. hello_proc = :hello.to_proc, SomeClass. Symbol # to_proc arity proc, , , proc, , .
C, :
class Symbol
def to_proc
method_name = self
proc {|receiver, *other_args| receiver.send(method_name, *other_args) }
end
end