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
Post a Comment