[#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:71499] Re: [Ruby trunk - Feature #11690] [Open] Update Hash during multiple assignment
From:
Matthew Kerwin <matthew@...>
Date:
2015-11-15 21:04:52 UTC
List:
ruby-core #71499
On 16/11/2015 2:32 AM, <6ftdan@gmail.com> wrote:
>
> This would be most useful in scenarios where a method or proc return
multiple values. When the method returns the values we don't normally know
the key outside where the hash assignment is.
>
> ~~~ruby
> example = proc { [{:hi => :hello}, 5] }
>
> hash = {}
>
> # Currently in Ruby with an Unknown key multiple assignment isn't an
option
> hash[????], current = example.call
>
> # We currently have to two step it
> result, current = example.call
> hash.update(result)
> ~~~
>
> But with `Hash#update=` we don't have to know the key.
>
I get the use-case, but I think the understandability of the code starts to
suffer.
What about something completely new but splat-like?
hash[*], current = example.call
This is even better when the hash comes last, it looks more like an options
parameter:
opts = get_default_hash
a, b, opts[*] = example2.call
I would assume this also works in single assignment:
opts = get_default_hash
opts[*] = get_new_opts