How do I pass a conditional expression as a parameter in Ruby?
- by srayhan
For example this what I am trying to do,
def method_a(condition, params={}, &block)
if condition
method_b(params, &block)
else
yield
end
end
and I am trying to call the method like this,
method_a(#{@date > Date.today}, {:param1 => 'value1', :param2 => 'value2'}) do
end
The result is the condition is always evaluated to true. How do I make it work?