Project

General

Profile

Actions

Bug #11771

closed

unable to pass keyargs to []=

Added by bughit (bug hit) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:71836]

Description

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 *


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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0