I would like to call a method in Ruby, which has an optional parameter.
I tried some ways, but none of them is working. Can you help me, how can I call this method? I never used Ruby before, so please help me refine the question itself. I tried googling the problem, but I think I use the wrong terms.
I read this: Ruby Methods and Optional parameters and this: A method with an optional parameter, but with no luck.
The method looks like this:
def method(param1, param2, options={})
...
if options["something"]
...
end
...
end
I tried the call, for example, like this:
method("param1", "param2", :something => true)
With my tries, the code runs but does not enter in the if
condition.
I would like to call this method in the way, that the codes in the if
statement would be run.