https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112019-10-23T06:45:25ZRuby Issue Tracking SystemRuby master - Feature #16273: Proposal: Shorthand operator for "#instance_method"https://redmine.ruby-lang.org/issues/16273?journal_id=822612019-10-23T06:45:25Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>I don't think using <code>#</code> acceptable, and have thought <code>.::</code>.</p> Ruby master - Feature #16273: Proposal: Shorthand operator for "#instance_method"https://redmine.ruby-lang.org/issues/16273?journal_id=822622019-10-23T06:49:23Znaruse (Yui NARUSE)naruse@airemix.jp
<ul></ul><p>I don't think <code>Array.instance_method(:zip).bind_call(*arrays)</code> should be recommended, and worth adding shorthand operator.</p> Ruby master - Feature #16273: Proposal: Shorthand operator for "#instance_method"https://redmine.ruby-lang.org/issues/16273?journal_id=822632019-10-23T07:12:49Zmrkn (Kenta Murata)muraken@gmail.com
<ul></ul><p>I don't think the first examples are messy.<br>
On the contrary, the second examples using <code>bind_call</code> are quite messy than the first.</p> Ruby master - Feature #16273: Proposal: Shorthand operator for "#instance_method"https://redmine.ruby-lang.org/issues/16273?journal_id=822652019-10-23T07:50:31Zzverok (Victor Shepelev)zverok.offline@gmail.com
<ul></ul><p>Funnily enough (and not completely intentionally) the problem is "solved" with <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Real "callable instance method" object. (Closed)" href="https://redmine.ruby-lang.org/issues/16264">#16264</a>:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="o">.</span><span class="ss">:zip</span><span class="p">.</span><span class="nf">call</span><span class="p">(</span><span class="o">*</span><span class="n">arrays</span><span class="p">)</span>
<span class="c1"># or even... for those who likes to cry "code golf!"</span>
<span class="o">.</span><span class="ss">:zip</span><span class="o">.</span><span class="p">(</span><span class="o">*</span><span class="n">arrays</span><span class="p">)</span>
</code></pre>
<p>Currently, you also can</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="ss">:zip</span><span class="p">.</span><span class="nf">to_proc</span><span class="p">.</span><span class="nf">call</span><span class="p">(</span><span class="o">*</span><span class="n">arrays</span><span class="p">)</span>
</code></pre>
<p>Though, I tend to agree with <a class="user active user-mention" href="https://redmine.ruby-lang.org/users/482">@mrkn (Kenta Murata)</a> that "no-tricks" first example looks pretty clear... But I understand that in codebase where this metaphor emerges regularly, it could become tiresome and too non-atomic to read.</p>
<p>One another non-orthodox suggestion (which uses <code>#then</code> loathed by some, but of all the rest of examples the only one which reads directly "zip first array with the rest of them"):</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">arrays</span><span class="p">.</span><span class="nf">then</span> <span class="p">{</span> <span class="o">|</span><span class="n">first</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="o">|</span> <span class="n">first</span><span class="p">.</span><span class="nf">zip</span><span class="p">(</span><span class="o">*</span><span class="n">rest</span><span class="p">)</span> <span class="p">}</span>
</code></pre> Ruby master - Feature #16273: Proposal: Shorthand operator for "#instance_method"https://redmine.ruby-lang.org/issues/16273?journal_id=838222020-01-13T12:23:37Zznz (Kazuhiro NISHIYAMA)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" title="Mention new feature of Hash#transform_keys [Feature #16273] ref b25e27277dc39f25cfca4db8452d254f..." href="https://redmine.ruby-lang.org/projects/ruby-master/repository/git/revisions/5aa0e6bee916f454ecf886252e1b025d824f7bd8">git|5aa0e6bee916f454ecf886252e1b025d824f7bd8</a>.</p>
<hr>
<p>Mention new feature of Hash#transform_keys [Feature <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Proposal: Shorthand operator for "#instance_method" (Open)" href="https://redmine.ruby-lang.org/issues/16273">#16273</a>]</p>
<p>ref b25e27277dc39f25cfca4db8452d254f6cc8046e</p> Ruby master - Feature #16273: Proposal: Shorthand operator for "#instance_method"https://redmine.ruby-lang.org/issues/16273?journal_id=838602020-01-14T12:24:25Zznz (Kazuhiro NISHIYAMA)
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li></ul>