[#71439] [Ruby trunk - Feature #11339] [PATCH] io.c: avoid kwarg parsing in C API — matz@...
Issue #11339 has been updated by Yukihiro Matsumoto.
7 messages
2015/11/11
[#71473] Re: [Ruby trunk - Feature #11339] [PATCH] io.c: avoid kwarg parsing in C API
— Eric Wong <normalperson@...>
2015/11/13
Entire series for sockets
[#71450] Ruby 2.3.0-preview1 Released — "NARUSE, Yui" <naruse@...>
Hi,
5 messages
2015/11/11
[#71617] [Ruby trunk - Feature #11664] [PATCH] introduce rb_autoload_value to replace rb_autoload — nobu@...
Issue #11664 has been updated by Nobuyoshi Nakada.
3 messages
2015/11/20
[#71721] [Ruby trunk - Feature #11741] Migrate Ruby to Git from Subversion — me@...
Issue #11741 has been updated by Jon Moss.
4 messages
2015/11/28
[ruby-core:71508] Re: [Ruby trunk - Feature #11690] Update Hash during multiple assignment
From:
Matthew Kerwin <matthew@...>
Date:
2015-11-16 21:31:09 UTC
List:
ruby-core #71508
On 17/11/2015 12:18 AM, <6ftdan@gmail.com> wrote:
>
> Issue #11690 has been updated by Daniel P. Clark.
>
>
> I'm not sure the opts[*] is a good idea. You have have current splat
behavior with multiple assignment.
>
> ~~~ruby
> a, *, c = [1,2,3,4,5]
> a
> # => 1
> c
> # => 5
> ~~~
>
> And the opts[*] is unclear about what it is and what it expects. It
could be a Proc.
>
> ~~~ruby
> prc = proc {|b,c,d| b+c+d }
> # if [*] were implemented
> a, prc[*], c = [1,2,3,4,5]
> ~~~
>
Good point. I won't suggest anything to do with hash-splatting ** ;)
> As far as I know **Hash** is the only core object with an **update**
method. And in other cases where **update** is used, such as in Rails'
ActiveRecord, a Hash is the expected input. So when the **update** method
is called it is generally understood to be expecting a **Hash** object.
>
> Implementing [*] would be much more work that simply implementing
`Hash#update=`
>
> I was thinking about suggesting `Hash#merge!=` as well but Ruby syntax
does not allow the equals sign after and exclamation point. So I have
chosen to only suggest `Hash#update=`
>
> ~~~ruby
> class Hash
> def update=(h)
> update(h)
> end
> end
> ~~~
>
It's still very strange to think of 'update' as a property of a hash
object. Without some kind of new syntactic construct, with its own clear
semantics, this seems like a hack and doesn't feel right in the core (to
me; others may disagree.)