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 -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -