diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-05-19 22:15:27 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-05-19 22:17:56 +0900 |
| commit | 8e637bdd83505e8c1723f87a8d267e00ee209787 (patch) | |
| tree | 9c862fa8015f64d8e0f730679885c6fb25de93e5 /mrbgems/mruby-object-ext/mrblib/object.rb | |
| parent | 1cdb3ec93c09629dd24cab8a5e8f66ae6d26bf60 (diff) | |
| download | mruby-8e637bdd83505e8c1723f87a8d267e00ee209787.tar.gz mruby-8e637bdd83505e8c1723f87a8d267e00ee209787.zip | |
Should clarify the role of `mruby-kernel-ext` and `mruby-object-ext`; close #4449
The former should contain function like methods, and the latter should
contain methods shared by all objects.
Diffstat (limited to 'mrbgems/mruby-object-ext/mrblib/object.rb')
| -rw-r--r-- | mrbgems/mruby-object-ext/mrblib/object.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/mrbgems/mruby-object-ext/mrblib/object.rb b/mrbgems/mruby-object-ext/mrblib/object.rb index 581156cb0..f014df469 100644 --- a/mrbgems/mruby-object-ext/mrblib/object.rb +++ b/mrbgems/mruby-object-ext/mrblib/object.rb @@ -1,4 +1,18 @@ -class Object +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 + ## # call-seq: # obj.tap{|x|...} -> obj |
