Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Kernel#yield_self
obj.yield_self {|x| block } → an_object
kernel.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/kernel.rb, line 144
def yield_self
unless block_given?
return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, rb_obj_size)'
end
yield(self)
end
Yields self to the block and returns the result of the block.
Example
"my string".yield_self {|s| s.upcase } #=> "MY STRING"