From: "shugo (Shugo Maeda)" Date: 2012-03-25T02:07:55+09:00 Subject: [ruby-core:43588] [ruby-trunk - Bug #6159] Enumerable::Lazy#inspect Issue #6159 has been updated by shugo (Shugo Maeda). Eregon (Benoit Daloze) wrote: > Your answer raises another question: Would it not be more readable if #inspect was closer to the code? > > (1..10).lazy.select(&:odd?).map(&:to_s).cycle(2).inspect > Instead of > "#:select>:map>:cycle(2)>" > Something like > "#" > ? The former can distinguish the following lazy enumerators, but the latter can't: p (1..10).lazy.select(&:odd).map(&:to_s) #=> #:select>:map> p (1..10).select.lazy.map(&:to_s) #=> #>:map> p (1..10).select.map.lazy #=> #:map>> So I prefer the current behavior. ---------------------------------------- Bug #6159: Enumerable::Lazy#inspect https://bugs.ruby-lang.org/issues/6159#change-25085 Author: Eregon (Benoit Daloze) Status: Closed Priority: Normal Assignee: shugo (Shugo Maeda) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-03-15 trunk 35042) [x86_64-darwin10.8.0] Hello, Enumerable::Lazy#inspect is undefined right now and relies on Enumerator#inspect: (1..5).lazy # => #:each> I think it would be nice to be similar to (direct) Enumerator#inspect: (1..5).each # => # So something like: # or #> It would also be nice to show the chaining, like Enumerator does: (1..5).select.map.flat_map # => #:map>:flat_map> What do you think? -- http://bugs.ruby-lang.org/