[前][次][番号順一覧][スレッド一覧]

ruby-changes:58358

From: Yusuke <ko1@a...>
Date: Tue, 22 Oct 2019 19:47:11 +0900 (JST)
Subject: [ruby-changes:58358] 02aadf1032 (master): NEWS: Fix the example of Lazy#eager

https://git.ruby-lang.org/ruby.git/commit/?id=02aadf1032

From 02aadf1032d71a3f81653a955f2635c8853b0aca Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Tue, 22 Oct 2019 19:46:44 +0900
Subject: NEWS: Fix the example of Lazy#eager


diff --git a/NEWS b/NEWS
index 8165b87..9352f39 100644
--- a/NEWS
+++ b/NEWS
@@ -252,13 +252,9 @@ Enumerator:: https://github.com/ruby/ruby/blob/trunk/NEWS#L252
       from a lazy enumerator.  [Feature #15901]
 
         a = %w(foo bar baz)
-        e = a.lazy
-             .map {|x| p [x, :upcase]; x.upcase }
-             .map {|x| p [x, :add_bang]; x + "!" }
-             .eager
-        p e.next #=> ["foo", :upcase], ["FOO", :add_bang], "FOO!"
-        p e.next #=> ["bar", :upcase], ["BAR", :add_bang], "BAR!"
-        p e.next #=> ["baz", :upcase], ["BAZ", :add_bang], "BAZ!"
+        e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
+        p e.class               #=> Enumerator
+        p e.map {|x| x + "?" }  #=> ["FOO!?", "BAR!?", "BAZ!?"]
 
     * Added Enumerator::Yielder#to_proc so that a Yielder object
       can be directly passed to another method as a block
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]