Feature #9783 » 0001-Implement-Method-curry-which-delegates-to-to_proc.cu.patch
proc.c | ||
---|---|---|
}
|
||
VALUE
|
||
rb_method_curry(int argc, VALUE *argv, VALUE self)
|
||
{
|
||
VALUE proc = rb_funcall(self, rb_intern("to_proc"), 0);
|
||
return rb_funcall2(proc, rb_intern("curry"), argc, argv);
|
||
}
|
||
VALUE
|
||
rb_method_call_with_block(int argc, VALUE *argv, VALUE method, VALUE pass_procval)
|
||
{
|
||
VALUE result = Qnil; /* OK */
|
||
... | ... | |
rb_define_method(rb_cMethod, "hash", method_hash, 0);
|
||
rb_define_method(rb_cMethod, "clone", method_clone, 0);
|
||
rb_define_method(rb_cMethod, "call", rb_method_call, -1);
|
||
rb_define_method(rb_cMethod, "curry", rb_method_curry, -1);
|
||
rb_define_method(rb_cMethod, "[]", rb_method_call, -1);
|
||
rb_define_method(rb_cMethod, "arity", method_arity_m, 0);
|
||
rb_define_method(rb_cMethod, "inspect", method_inspect, 0);
|
test/ruby/test_method.rb | ||
---|---|---|
m = assert_nothing_raised(NameError, feature8391) {break o.singleton_method(:bar)}
|
||
assert_equal(:bar, m.call, feature8391)
|
||
end
|
||
def test_curry
|
||
c = Class.new
|
||
p = proc {|a,b,c| a + b + c }
|
||
c.class_eval { define_method(:three_args, p) }
|
||
curried = c.new.method(:three_args).curry
|
||
assert_equal(6, curried.(1).(2).(3))
|
||
end
|
||
end
|