Skipping extra keyword arguments in Ruby -


i defined method:

def method(one: 1, two: 2)    [one, two] end 

and when call this:

method one: 'one', three: 'three' 

i get:

argumenterror: unknown keyword: 3 

i not want extract desired keys hash 1 one or exclude keys. there way circumvent behaviour except defining method this:

def method(one: 1, two: 2, **other)   [one, two, other] end 

if don't want write other in **other, can omit it.

def method(one: 1, two: 2, **)   [one, two] end 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -