Creating a setter method that takes extra arguments in Ruby
It doesn't work because the parser doesn't allow it. An equals sign is allowed in expressions of the form identifier = expression
, expression.identifier = expression
(where identifier is \w+
), expression[arguments] = expression
and expression.[]= arguments
and as part of a string or symbol or character literal (?=
). That's it.
gen.send(:allow=, 'a', 1, false)
would work, but at that point you could as well just give the method a name that doesn't include a =
.