Feature #841 ยป tap-without-block.patch
object.c (working copy) | ||
---|---|---|
/*
|
||
* call-seq:
|
||
* obj.tap => obj
|
||
* obj.tap{|x|...} => obj
|
||
*
|
||
* Yields <code>x</code> to the block, and then returns <code>x</code>.
|
||
* Yields <code>x</code> to the block if given, and then returns <code>x</code>.
|
||
* The primary purpose of this method is to "tap into" a method chain,
|
||
* in order to perform operations on intermediate results within the chain.
|
||
*
|
||
... | ... | |
VALUE
|
||
rb_obj_tap(VALUE obj)
|
||
{
|
||
rb_yield(obj);
|
||
if (rb_block_given_p()) {
|
||
rb_yield(obj);
|
||
}
|
||
return obj;
|
||
}
|
||