mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
c8fb7453fc
`then' was added in CRuby 2.6.
16 lines
361 B
Ruby
16 lines
361 B
Ruby
module Kernel
|
|
# call-seq:
|
|
# obj.yield_self {|_obj|...} -> an_object
|
|
# obj.then {|_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
|
|
alias then yield_self
|
|
end
|