https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112016-02-23T10:19:11ZRuby Issue Tracking SystemRuby master - Bug #12104: Procs keyword arguments affect value of previous argumenthttps://bugs.ruby-lang.org/issues/12104?journal_id=570992016-02-23T10:19:11Zcheerfulstoic (Brian Underwood)public@brian-underwood.codes
<ul></ul><p>This seems to also happen when trying to use a options Hash as the second argument:</p>
<pre><code>2.3.0 :009 > p = Proc.new {|nodes, options = {}| puts nodes.inspect }
=> #<Proc:0x007fa52b13b348@(irb):9>
2.3.0 :010 > p.call([])
nil
=> nil
2.3.0 :011 > p.call([], match_array: true)
[]
</code></pre> Ruby master - Bug #12104: Procs keyword arguments affect value of previous argumenthttps://bugs.ruby-lang.org/issues/12104?journal_id=571002016-02-23T10:26:53Zcheerfulstoic (Brian Underwood)public@brian-underwood.codes
<ul></ul><p>Looking deeper now it seems to be that this is because the first argument is an Array and that when that happens it's interpreting that as the elements of the array being the arguments of the Proc. Is that supposed to happen?</p> Ruby master - Bug #12104: Procs keyword arguments affect value of previous argumenthttps://bugs.ruby-lang.org/issues/12104?journal_id=574942016-03-16T09:39:52Zko1 (Koichi Sasada)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>You are right.<br>
It is intentional.</p> Ruby master - Bug #12104: Procs keyword arguments affect value of previous argumenthttps://bugs.ruby-lang.org/issues/12104?journal_id=575022016-03-16T13:01:57Zznz (Kazuhiro NISHIYAMA)
<ul></ul><p>How about using <code>lambda</code> instead of <code>Proc.new</code>?</p>
<pre><code>>> p = lambda {|nodes, match_array: false| puts nodes.inspect }
=> #<Proc:0x0000000183a0a8@(irb):1 (lambda)>
>> p.call([])
[]
=> nil
>> p = lambda {|nodes, options = {}| puts nodes.inspect }
=> #<Proc:0x00000001850c68@(irb):3 (lambda)>
>> p.call([])
[]
=> nil
</code></pre> Ruby master - Bug #12104: Procs keyword arguments affect value of previous argumenthttps://bugs.ruby-lang.org/issues/12104?journal_id=683952017-12-14T07:24:21Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/14183">Feature #14183</a>: "Real" keyword argument</i> added</li></ul> Ruby master - Bug #12104: Procs keyword arguments affect value of previous argumenthttps://bugs.ruby-lang.org/issues/12104?journal_id=739052018-09-05T15:33:21Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<ul><li><strong>Related to</strong> deleted (<i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/14183">Feature #14183</a>: "Real" keyword argument</i>)</li></ul>