[#74190] [Ruby trunk Feature#12134] Comparison between `true` and `false` — duerst@...
SXNzdWUgIzEyMTM0IGhhcyBiZWVuIHVwZGF0ZWQgYnkgTWFydGluIETDvHJzdC4KCgpUc3V5b3No
3 messages
2016/03/07
[#74269] Type systems for Ruby — Rob Blanco <ml@...>
Dear ruby-core,
5 messages
2016/03/10
[#74395] [Ruby trunk Feature#12142] Hash tables with open addressing — shyouhei@...
Issue #12142 has been updated by Shyouhei Urabe.
3 messages
2016/03/17
[ruby-core:74382] [Ruby trunk Bug#12104] Procs keyword arguments affect value of previous argument
From:
zn@...
Date:
2016-03-16 13:01:58 UTC
List:
ruby-core #74382
Issue #12104 has been updated by Kazuhiro NISHIYAMA.
How about using `lambda` instead of `Proc.new`?
```
>> 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
```
----------------------------------------
Bug #12104: Procs keyword arguments affect value of previous argument
https://bugs.ruby-lang.org/issues/12104#change-57502
* Author: Brian Underwood
* Status: Rejected
* Priority: Normal
* Assignee:
* ruby -v: Tested in 2.3.0 and 2.2.3
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
This seems like a bug to me:
~~~
2.3.0 :001 > p = Proc.new {|nodes, match_array: false| puts nodes.inspect }
=> #<Proc:0x007fa52c0659e0@(irb):1>
2.3.0 :002 > p.call([])
nil
=> nil
2.3.0 :003 > p.call([], match_array: true)
[]
=> nil
~~~
When I try the same thing in a method I get the behavior I would expect:
~~~
2.3.0 :004 > def foo(nodes, match_array: false)
2.3.0 :005?> puts nodes.inspect
2.3.0 :006?> end
=> :foo
2.3.0 :007 > foo([])
[]
=> nil
2.3.0 :008 > foo([], match_array: true)
[]
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>