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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -