Is there a way to do python's kwargs passthrough in ruby 1.9.3? -


so have functions in ruby 1.9 really, nice functional equivalent of this:

def foo(**kwargs):     ...do stuff...  def bar(**kwargs):     foo(x = 2, y = 3, **kwargs) 

so ruby has opts, if this:

def f(opts)     print opts.keys end  def g(opts)     f(opts, :bar=>3) end  g(:foo => 1) 

i get:

script:1:in f': wrong number of arguments (2 1) (argumenterror) script:6:in g' script:9:in <main>'

is there way pass opts through g f?

your

def g(opts)     f(opts, :bar=>3) end 

passes 2 arguments f. let pass one, this:

def g(opts)     f(opts.merge(:bar=>3)) end 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -