* [ruby-dev:44962] [ruby-trunk - Feature #5735][Open] Extending the use of splat operator to when it is inside a hash
@ 2011-12-09 4:31 Tsuyoshi Sawada
2012-03-28 15:57 ` [ruby-dev:45452] [ruby-trunk - Feature #5735][Feedback] " mame (Yusuke Endoh)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tsuyoshi Sawada @ 2011-12-09 4:31 UTC (permalink / raw)
To: ruby developers list
Issue #5735 has been reported by Tsuyoshi Sawada.
----------------------------------------
Feature #5735: Extending the use of splat operator to when it is inside a hash
http://redmine.ruby-lang.org/issues/5735
Author: Tsuyoshi Sawada
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
Ruby convention of allowing omittion of the curly brackets for the last argument is convenient:
foo(arg1, arg2, 1 => :a, 2 => :b)
Sometimes, I want to pass a hash with some modifications. For example, suppose `h = {3 => :c, 4 => :d, 5 => :e}` is a hash already defined and that I want to add some key-value pairs as well as overwrite some values of `h`, such as {3 => :c, 4 => :f, 5 => :e, 6 => :g}, and pass that. The current convention only allows:
foo(arg1, arg2, h.merge(4 => :f, 6 => :g))
but it would be more convenient if a hash preceded by the splat operator is placed in a hash, it is interpreted as part of the hash, allowing notations like:
foo(arg1, arg2, *h, 4 => :f, 6 => :g)
or, if I want to overwrite the hash `{4 => :f, 6 => :g}` with `h`, then:
foo(arg1, arg2, 4 => :f, 6 => :g, *h)
Or besides the argument position, in general, usages like the following:
{3 => :h, *h, 4 => :f, 6 => :g}
This is an analogy from the splat operator used within an array:
[1, 2, *[4, 5, 6], 7, 8]
--
http://redmine.ruby-lang.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-dev:45452] [ruby-trunk - Feature #5735][Feedback] Extending the use of splat operator to when it is inside a hash
2011-12-09 4:31 [ruby-dev:44962] [ruby-trunk - Feature #5735][Open] Extending the use of splat operator to when it is inside a hash Tsuyoshi Sawada
@ 2012-03-28 15:57 ` mame (Yusuke Endoh)
2012-11-20 12:57 ` [ruby-dev:46561] [ruby-trunk - Feature #5735] " mame (Yusuke Endoh)
2019-07-08 9:53 ` [ruby-dev:50811] [Ruby master Feature#5735] " sawadatsuyoshi
2 siblings, 0 replies; 4+ messages in thread
From: mame (Yusuke Endoh) @ 2012-03-28 15:57 UTC (permalink / raw)
To: ruby developers list
Issue #5735 has been updated by mame (Yusuke Endoh).
Status changed from Open to Feedback
Assignee set to matz (Yukihiro Matsumoto)
Marc-Andre proposed a similar idea at [ruby-core:41772], and Matz commented a little at [ruby-core:41822].
It would be good to investigate how many use cases occur in real world.
matz wrote:
> I am still not sure if we need hash splat nor hash decomposition, it
> might be useful in some cases, but also makes syntax more complex.
> So we need more discussion before picking it.
>
> But if we could made consensus I'd make small changes to proposed
> syntax.
>
> For hash splat, I'd rather use ** instead of *, because splat in array
> and splat in hash are different. Using same operator could cause
> confusion. Besides that, I would also restrict hash splat position to
> the end, since hashes do not have order.
--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Feature #5735: Extending the use of splat operator to when it is inside a hash
https://bugs.ruby-lang.org/issues/5735#change-25303
Author: sawa (Tsuyoshi Sawada)
Status: Feedback
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version:
Ruby convention of allowing omittion of the curly brackets for the last argument is convenient:
foo(arg1, arg2, 1 => :a, 2 => :b)
Sometimes, I want to pass a hash with some modifications. For example, suppose `h = {3 => :c, 4 => :d, 5 => :e}` is a hash already defined and that I want to add some key-value pairs as well as overwrite some values of `h`, such as {3 => :c, 4 => :f, 5 => :e, 6 => :g}, and pass that. The current convention only allows:
foo(arg1, arg2, h.merge(4 => :f, 6 => :g))
but it would be more convenient if a hash preceded by the splat operator is placed in a hash, it is interpreted as part of the hash, allowing notations like:
foo(arg1, arg2, *h, 4 => :f, 6 => :g)
or, if I want to overwrite the hash `{4 => :f, 6 => :g}` with `h`, then:
foo(arg1, arg2, 4 => :f, 6 => :g, *h)
Or besides the argument position, in general, usages like the following:
{3 => :h, *h, 4 => :f, 6 => :g}
This is an analogy from the splat operator used within an array:
[1, 2, *[4, 5, 6], 7, 8]
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-dev:46561] [ruby-trunk - Feature #5735] Extending the use of splat operator to when it is inside a hash
2011-12-09 4:31 [ruby-dev:44962] [ruby-trunk - Feature #5735][Open] Extending the use of splat operator to when it is inside a hash Tsuyoshi Sawada
2012-03-28 15:57 ` [ruby-dev:45452] [ruby-trunk - Feature #5735][Feedback] " mame (Yusuke Endoh)
@ 2012-11-20 12:57 ` mame (Yusuke Endoh)
2019-07-08 9:53 ` [ruby-dev:50811] [Ruby master Feature#5735] " sawadatsuyoshi
2 siblings, 0 replies; 4+ messages in thread
From: mame (Yusuke Endoh) @ 2012-11-20 12:57 UTC (permalink / raw)
To: ruby developers list
Issue #5735 has been updated by mame (Yusuke Endoh).
Target version set to next minor
----------------------------------------
Feature #5735: Extending the use of splat operator to when it is inside a hash
https://bugs.ruby-lang.org/issues/5735#change-33261
Author: sawa (Tsuyoshi Sawada)
Status: Feedback
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version: next minor
Ruby convention of allowing omittion of the curly brackets for the last argument is convenient:
foo(arg1, arg2, 1 => :a, 2 => :b)
Sometimes, I want to pass a hash with some modifications. For example, suppose `h = {3 => :c, 4 => :d, 5 => :e}` is a hash already defined and that I want to add some key-value pairs as well as overwrite some values of `h`, such as {3 => :c, 4 => :f, 5 => :e, 6 => :g}, and pass that. The current convention only allows:
foo(arg1, arg2, h.merge(4 => :f, 6 => :g))
but it would be more convenient if a hash preceded by the splat operator is placed in a hash, it is interpreted as part of the hash, allowing notations like:
foo(arg1, arg2, *h, 4 => :f, 6 => :g)
or, if I want to overwrite the hash `{4 => :f, 6 => :g}` with `h`, then:
foo(arg1, arg2, 4 => :f, 6 => :g, *h)
Or besides the argument position, in general, usages like the following:
{3 => :h, *h, 4 => :f, 6 => :g}
This is an analogy from the splat operator used within an array:
[1, 2, *[4, 5, 6], 7, 8]
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-dev:50811] [Ruby master Feature#5735] Extending the use of splat operator to when it is inside a hash
2011-12-09 4:31 [ruby-dev:44962] [ruby-trunk - Feature #5735][Open] Extending the use of splat operator to when it is inside a hash Tsuyoshi Sawada
2012-03-28 15:57 ` [ruby-dev:45452] [ruby-trunk - Feature #5735][Feedback] " mame (Yusuke Endoh)
2012-11-20 12:57 ` [ruby-dev:46561] [ruby-trunk - Feature #5735] " mame (Yusuke Endoh)
@ 2019-07-08 9:53 ` sawadatsuyoshi
2 siblings, 0 replies; 4+ messages in thread
From: sawadatsuyoshi @ 2019-07-08 9:53 UTC (permalink / raw)
To: ruby-dev
Issue #5735 has been updated by sawa (Tsuyoshi Sawada).
A similar feature has already been realized as the double splat operator. Please close this issue.
----------------------------------------
Feature #5735: Extending the use of splat operator to when it is inside a hash
https://bugs.ruby-lang.org/issues/5735#change-79211
* Author: sawa (Tsuyoshi Sawada)
* Status: Feedback
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
----------------------------------------
Ruby convention of allowing omittion of the curly brackets for the last argument is convenient:
foo(arg1, arg2, 1 => :a, 2 => :b)
Sometimes, I want to pass a hash with some modifications. For example, suppose `h = {3 => :c, 4 => :d, 5 => :e}` is a hash already defined and that I want to add some key-value pairs as well as overwrite some values of `h`, such as {3 => :c, 4 => :f, 5 => :e, 6 => :g}, and pass that. The current convention only allows:
foo(arg1, arg2, h.merge(4 => :f, 6 => :g))
but it would be more convenient if a hash preceded by the splat operator is placed in a hash, it is interpreted as part of the hash, allowing notations like:
foo(arg1, arg2, *h, 4 => :f, 6 => :g)
or, if I want to overwrite the hash `{4 => :f, 6 => :g}` with `h`, then:
foo(arg1, arg2, 4 => :f, 6 => :g, *h)
Or besides the argument position, in general, usages like the following:
{3 => :h, *h, 4 => :f, 6 => :g}
This is an analogy from the splat operator used within an array:
[1, 2, *[4, 5, 6], 7, 8]
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-08 9:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-09 4:31 [ruby-dev:44962] [ruby-trunk - Feature #5735][Open] Extending the use of splat operator to when it is inside a hash Tsuyoshi Sawada
2012-03-28 15:57 ` [ruby-dev:45452] [ruby-trunk - Feature #5735][Feedback] " mame (Yusuke Endoh)
2012-11-20 12:57 ` [ruby-dev:46561] [ruby-trunk - Feature #5735] " mame (Yusuke Endoh)
2019-07-08 9:53 ` [ruby-dev:50811] [Ruby master Feature#5735] " sawadatsuyoshi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).