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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -