Class: Object

Inherits:
BasicObject
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#yield_self {|x| ... } ⇒ Object

Yields self to the block and returns the result of the block.

"my string".yield_self {|s| s.upcase }   #=> "MY STRING"
3.next.yield_self {|x| x**x }.to_s       #=> "256"

Yields:

  • (x)

Returns:



42
43
44
45
46
47
# File 'ext/backport_yield_self/backport_yield_self.c', line 42

static VALUE
rb_obj_yield_self(VALUE obj)
{
    RETURN_SIZED_ENUMERATOR(obj, 0, 0, rb_obj_size);
    return rb_yield_values2(1, &obj);
}