https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112020-06-26T17:18:14ZRuby Issue Tracking SystemRuby master - Feature #16987: Enumerator::Lazy vs Array methodshttps://redmine.ruby-lang.org/issues/16987?journal_id=863372020-06-26T17:18:14Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/86337/diff?detail_id=57407">diff</a>)</li></ul> Ruby master - Feature #16987: Enumerator::Lazy vs Array methodshttps://redmine.ruby-lang.org/issues/16987?journal_id=863382020-06-26T17:21:33Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/86338/diff?detail_id=57408">diff</a>)</li></ul> Ruby master - Feature #16987: Enumerator::Lazy vs Array methodshttps://redmine.ruby-lang.org/issues/16987?journal_id=865612020-07-15T16:56:21Zmidnight (Sarun R)
<ul></ul><p>I used Lazy all the time. There is nothing to be done here about its popularity.<br>
FWIW, People knew about it, but choose not to rely on it because they want to support old versions of Ruby.<br>
Hence, it is not very popular in open-source settings.</p>
<p>Regardless of what should be implemented, for now, you can use</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">lazy</span><span class="p">.</span><span class="nf">flat_map</span><span class="p">(</span><span class="o">&</span><span class="ss">:itself</span><span class="p">)</span>
</code></pre>
<p>as <code>#flatten</code>, and</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">lazy</span><span class="p">.</span><span class="nf">select</span><span class="p">(</span><span class="o">&</span><span class="ss">:itself</span><span class="p">)</span>
</code></pre>
<p>as <code>#compact</code>.</p>
<p>Only <code>#product</code> is the tricky one that requires multiple operations, but it is not used very often anyway.</p>
<p>What I missed most is <code>#scan</code>.<br>
<a href="https://ramdajs.com/docs/#scan" class="external">https://ramdajs.com/docs/#scan</a><br>
It is basically a <code>#reduce</code> that yield at every iteration.</p> Ruby master - Feature #16987: Enumerator::Lazy vs Array methodshttps://redmine.ruby-lang.org/issues/16987?journal_id=886312020-11-20T08:32:21Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/17312">Feature #17312</a>: New methods in Enumerable and Enumerator::Lazy: flatten, product, compact</i> added</li></ul> Ruby master - Feature #16987: Enumerator::Lazy vs Array methodshttps://redmine.ruby-lang.org/issues/16987?journal_id=985192022-07-29T15:15:40Zzverok (Victor Shepelev)zverok.offline@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul>