D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Kernel
/
Filename :
then-i.ri
back
Copy
U:RDoc::AnyMethod[iI" then:ETI"Kernel#then;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"BYields self to the block and returns the result of the block.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"83.next.then {|x| x**x }.to_s #=> "256" ;T:@format0o; ; [I";A good use of +then+ is value piping in method chains:;T@o;; [I"require 'open-uri' ;TI"require 'json' ;TI" ;TI"construct_url(arguments) ;TI"$ .then {|url| URI(url).read } ;TI"0 .then {|response| JSON.parse(response) } ;T; 0o; ; [I"FWhen called without a block, the method returns an +Enumerator+, ;TI"5which can be used, for example, for conditional ;TI"circuit-breaking:;T@o;; [ I"# Meets condition, no-op ;TI"-1.then.detect(&:odd?) # => 1 ;TI"+# Does not meet condition, drop value ;TI".2.then.detect(&:odd?) # => nil;T; 0: @fileI"kernel.rb;T:0@omit_headings_from_table_of_contents_below0I"1obj.then {|x| block } -> an_object ;TI"