Files
mruby-mruby/mrbgems/mruby-kernel-ext/mrblib/kernel.rb
T
Yukihiro "Matz" Matsumoto 1519616ecb Add Kernel#yield_self; CRuby2.5
2017-10-17 09:10:13 +09:00

14 lines
291 B
Ruby

module Kernel
# call-seq:
# obj.yield_self {|_obj|...} -> an_object
#
# Yields <i>obj</i> and returns the result.
#
# 'my string'.yield_self {|s|s.upcase} #=> "MY STRING"
#
def yield_self(&block)
return to_enum :yield_self unless block
block.call(self)
end
end