If I have a method in ruby ββthat takes named arguments ...
def smoosh(first: nil, second: nil) first + second end
The easiest way to pass a hash to this method if the keys match:
params = { first: 'peanut', second: 'butter' } smoosh(params)
The above argument error.
Update:
It looks like this might be a problem with the Sinatra options.
When I do this:
get 'a_sinatra_route' do hash = params.clone hash.symbolize_keys! smoosh(hash) end
It works great. This does not work when you just pass the parameters yourself. (even if you can access individual parameters using the params[:attr] symbol key)
source share