Actions
Feature #11758
closedAdd keyword assignment syntax
Description
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:
a:, b: = {a: 1, b: 2}
A useful use case is returning keywords instead of multiple values making the values position independent:
def foo
return a: 1, b: 2
end
a:, b: = foo
puts a # => 1
puts b # => 2
Updated by ko1 (Koichi Sasada) almost 9 years ago
- Assignee set to matz (Yukihiro Matsumoto)
discuss for 2.4 and later
Updated by josh.cheek (Josh Cheek) almost 9 years ago
I keep trying to do this, too, and being surprised when it doesn't work.
Updated by jeremyevans0 (Jeremy Evans) about 3 years ago
- Status changed from Open to Closed
Actions
Like0
Like0Like0Like0