https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-01-05T13:06:21ZRuby Issue Tracking SystemRuby master - Feature #5735: Extending the use of splat operator to when it is inside a hashhttps://redmine.ruby-lang.org/issues/5735?journal_id=231142012-01-05T13:06:21Zkernigh (George Koehler)xkernigh@netscape.net
<ul></ul><p>=begin<br>
Ruby trunk has a hash splat operator because of feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: keyword argument (Closed)" href="https://redmine.ruby-lang.org/issues/5474">#5474</a>, keyword argument. See ((<a href="URL:http://bugs.ruby-lang.org/issues/5474" class="external">URL:http://bugs.ruby-lang.org/issues/5474</a>)).</p>
<p>With this version of Ruby,</p>
<p>ruby 2.0.0dev (2012-01-04 trunk 34211) [x86_64-openbsd5.0]</p>
<p>I can run this code,</p>
<p>def eat(i: 1, **hash)<br>
printf "i is %p, hash is %p\n", i, hash<br>
end<br>
eat(h: 7, i: 8, j: 9)</p>
<a name="gt-i-is-8-hash-is-hgt7-jgt9"></a>
<h1 >=> "i is 8, hash is {:h=>7, :j=>9}"<a href="#gt-i-is-8-hash-is-hgt7-jgt9" class="wiki-anchor">¶</a></h1>
<p>So far, **hash only works when defining a method. We cannot (yet) use **hash in a method call or a hash literal.</p>
<p>args = {h: 2, i: 3, j: 4}<br>
eat(**args) # syntax error!<br>
args = {k: 5, **args} # syntax error!</p>
<p>There is much more discussion of hash splat at feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: keyword argument (Closed)" href="https://redmine.ruby-lang.org/issues/5474">#5474</a>.<br>
=end</p> Ruby master - Feature #5735: Extending the use of splat operator to when it is inside a hashhttps://redmine.ruby-lang.org/issues/5735?journal_id=253032012-03-29T00:57:41Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li></ul><p>Marc-Andre proposed a similar idea at <a href="/issues/5474">[ruby-core:41772]</a>, and Matz commented a little at <a href="/issues/5474">[ruby-core:41822]</a>.<br>
It would be good to investigate how many use cases occur in real world.</p>
<p>matz wrote:</p>
<blockquote>
<p>I am still not sure if we need hash splat nor hash decomposition, it<br>
might be useful in some cases, but also makes syntax more complex.<br>
So we need more discussion before picking it.</p>
<p>But if we could made consensus I'd make small changes to proposed<br>
syntax.</p>
<p>For hash splat, I'd rather use ** instead of *, because splat in array<br>
and splat in hash are different. Using same operator could cause<br>
confusion. Besides that, I would also restrict hash splat position to<br>
the end, since hashes do not have order.</p>
</blockquote>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Feature #5735: Extending the use of splat operator to when it is inside a hashhttps://redmine.ruby-lang.org/issues/5735?journal_id=332612012-11-20T21:57:25Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Target version</strong> set to <i>2.6</i></li></ul> Ruby master - Feature #5735: Extending the use of splat operator to when it is inside a hashhttps://redmine.ruby-lang.org/issues/5735?journal_id=687372017-12-25T18:15:03Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>2.6</i></del>)</li></ul> Ruby master - Feature #5735: Extending the use of splat operator to when it is inside a hashhttps://redmine.ruby-lang.org/issues/5735?journal_id=792112019-07-08T09:53:15Zsawa (Tsuyoshi Sawada)
<ul></ul><p>A similar feature has already been realized as the double splat operator. Please close this issue.</p> Ruby master - Feature #5735: Extending the use of splat operator to when it is inside a hashhttps://redmine.ruby-lang.org/issues/5735?journal_id=792122019-07-08T10:02:29Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li></ul>