[#62904] [ruby-trunk - Feature #9894] [Open] [RFC] README.EXT: document rb_gc_register_mark_object — normalperson@...
Issue #9894 has been reported by Eric Wong.
3 messages
2014/06/02
[#63321] [ANN] ElixirConf 2014 - Don't Miss Jos辿 Valim and Dave Thomas — Jim Freeze <jimfreeze@...>
Just a few more weeks until ElixirConf 2014!
6 messages
2014/06/24
[#63391] Access Modifiers (Internal Interfaces) — Daniel da Silva Ferreira <danieldasilvaferreira@...>
Hi,
3 messages
2014/06/28
[ruby-core:62924] [ruby-trunk - Bug #9898] Keyword argument oddities
From:
nobu@...
Date:
2014-06-03 19:07:02 UTC
List:
ruby-core #62924
Issue #9898 has been updated by Nobuyoshi Nakada.
Description updated
Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED, 2.1: REQUIRED
----------------------------------------
Bug #9898: Keyword argument oddities
https://bugs.ruby-lang.org/issues/9898#change-47027
* Author: Brian Shirai
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
* Backport: 2.0.0: DONTNEED, 2.1: REQUIRED
----------------------------------------
Case 1: If a method takes a single argument, and the method is called with a keyword splat, the method receives the passed object, not the result of calling `#to_hash` on the object:
~~~ruby
# kw1.rb
def m(a) a end
o = Object.new
def o.to_hash() puts "to_hash"; { a: 1 } end
p m(**o)
~~~
~~~
$ ruby -v kw1.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
to_hash
#<Object:0x007fdee188ab90>
~~~
Would someone please explain why the result of `#to_hash` in not passed to the method?
Case 2: If the method takes a keyword argument, `#to_hash` is called at the send site and at the receiver:
~~~ruby
# kw2.rb
def mk(a:) a end
o = Object.new
def o.to_hash() puts "to_hash"; { a: 1 } end
p mk(**o)
~~~
~~~
$ ruby -v kw2.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
to_hash
to_hash
1
~~~
Would someone please explain why `#to_hash` is called at both the send site and at the receiver?
--
https://bugs.ruby-lang.org/