Reputation: 4459
My method:
def my_method=(attributes, some_option = true, another_option = true)
puts hello
end
When i try to call this, i get such error:
my_method=({:one => 'one', :two => 'two'}, 1, 1)
#you_code.rb:4: syntax error, unexpected ',', expecting ')'
#my_method=({:one => 'one', :two => 'two'}, 1, 1)
^
What's the problem?
Upvotes: 2
Views: 215
Reputation: 1008
Method with suffix punctuation =
can have only one argument.
Otherwise, you must use send
to invoke with multiple parameters.
send :'my_method=', {:a => 1}, 1, 1
Upvotes: 4
Reputation: 5629
Don't use parenthesis when invoking a method using the =
syntactic sugar.
Invoke it like this:
mymethod= {:one => 'one', :two => 'two'}, 1, 1
Upvotes: 0