Issue #11771 has been updated by Yukihiro Matsumoto.

Status changed from Open to Closed

Pending, for several reasons:

(1) compatibility. `a[a,foo:1]=v` is valid code. changing behavior may crash existing code.
(2) you can delegate to other method e.g.

```
def opt_aset(k,v,option:nil)
  ...
end

def []=(k,opt={},v)
  opt_aset(k,v,*opt)
end
```

Matz.

----------------------------------------
Bug #11771: unable to pass keyargs to []=
https://bugs.ruby-lang.org/issues/11771#change-55276

* Author: bug hit
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: 2.2.3
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
```ruby
module Foo
  def self.[]=(key, val, option: nil)

  end
end

Foo[:key] = 1 # ok


Foo[:key, option: 1] = 1 # wrong number of arguments (3 for 2)

```

if you declare the []= params using *

```ruby

module Bar
  def self.[]=(*args)
    p args
  end
end

Bar[:key, option: 1] = 1 # args: [:key, {:option=>1}, 1]

```

the args end up [:key, {:option=>1}, 1] which seems wrong since the keyargs hash is supposed to be last




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