Project

General

Profile

Actions

Feature #11758

closed

Add keyword assignment syntax

Added by elia (Elia Schito) over 8 years ago. Updated over 2 years ago.

Status:
Closed
Target version:
-
[ruby-core:71781]

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
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0