Issue #11758 has been updated by Josh Cheek.


I keep trying to do this, too, and being surprised when it doesn't work.

----------------------------------------
Feature #11758: Add keyword assignment syntax
https://bugs.ruby-lang.org/issues/11758#change-56994

* Author: Elia Schito
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
I think keyword assignments would be a useful addition, especially since the introduction of keyword arguments

The basic example would be, and is expected to work like required keyword arguments:

~~~ruby
a:, b: = {a: 1, b: 2}
~~~

A useful use case is returning keywords instead of multiple values making the values position independent:

~~~ruby
def foo
  return a: 1, b: 2
end

a:, b: = foo

puts a # => 1
puts b # => 2
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>