Project

General

Profile

Feature #13172 ยป method_pass.patch

Nondv (Dmitry Non), 02/17/2017 11:55 AM

View differences:

object.c
736 736
    return obj;
737 737
}
738 738

  
739
/*
740
 *  call-seq:
741
 *     obj.pass{|x|...}    -> block result
742
 *
743
 *  Yields self to the block, and then returns result.
744
 *
745
 *	Time.now.pass { |t| t.sunday? ? 'Yay!' : ':(' }
746
 *
747
 */
748

  
749
VALUE
750
rb_obj_pass(VALUE obj)
751
{
752
    return rb_yield(obj);
753
}
739 754

  
740 755
/*
741 756
 * Document-method: inherited
......
3510 3525
    rb_define_method(rb_mKernel, "kind_of?", rb_obj_is_kind_of, 1);
3511 3526
    rb_define_method(rb_mKernel, "is_a?", rb_obj_is_kind_of, 1);
3512 3527
    rb_define_method(rb_mKernel, "tap", rb_obj_tap, 0);
3528
    rb_define_method(rb_mKernel, "pass", rb_obj_pass, 0);
3513 3529

  
3514 3530
    rb_define_global_function("sprintf", rb_f_sprintf, -1); /* in sprintf.c */
3515 3531
    rb_define_global_function("format", rb_f_sprintf, -1);  /* in sprintf.c */