2

I need to create a method with a keyword argument, but I'm having some trouble. At the moment I have:

my_method(option_key:, location, options = {})

but I get the error:

syntax error, unexpected tIDENTIFIER (SyntaxError)

I'm not sure what I'm doing wrong, any help would be great.

Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145
user2320239
  • 1,021
  • 2
  • 18
  • 43

1 Answers1

4

Move the keyword args to the last position of the arguments list:

def my_method(location, options = {}, option_key:) 
end
Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145