summaryrefslogtreecommitdiff
path: root/kernel.rb
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikac.hu>2023-09-29 13:13:44 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-29 19:32:12 +0900
commit8d9e114f19ba0cbec41f63c77f3aef4d69834dfb (patch)
tree40f01e26cc8479b0fc5bc83fc6547c9d9f7b0f0b /kernel.rb
parent01c765677566f227854d737efcf2c06d139ddbac (diff)
Update documentation for `yield_self` and `then`
The example usage for `then` was mistakenly placed next to `yield_self`.
Diffstat (limited to 'kernel.rb')
-rw-r--r--kernel.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/kernel.rb b/kernel.rb
index 43d1abec31..c6b3e44000 100644
--- a/kernel.rb
+++ b/kernel.rb
@@ -117,6 +117,15 @@ module Kernel
# # does not meet condition, drop value
# 2.then.detect(&:odd?) # => nil
#
+ # Good usage for +then+ is value piping in method chains:
+ #
+ # require 'open-uri'
+ # require 'json'
+ #
+ # construct_url(arguments).
+ # then {|url| URI(url).read }.
+ # then {|response| JSON.parse(response) }
+ #
def then
unless block_given?
return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, rb_obj_size)'
@@ -132,15 +141,6 @@ module Kernel
#
# "my string".yield_self {|s| s.upcase } #=> "MY STRING"
#
- # Good usage for +then+ is value piping in method chains:
- #
- # require 'open-uri'
- # require 'json'
- #
- # construct_url(arguments).
- # then {|url| URI(url).read }.
- # then {|response| JSON.parse(response) }
- #
def yield_self
unless block_given?
return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, rb_obj_size)'