if the code is
do_more ||= true
then when false is passed in, it becomes
do_more = false || true
and therefore will still be true. So this is one case where foo ||= default_value won’t work? In this case it will need to be
do_more = true if !defined? do_more
?
More generally,
foo ||= default_valuenever works if a valid value for foo is false.foo ||= default_valueis only a valid pattern when all valid values are interpreted as boolean TRUE.Your statement of
do_more == true if !defined? do_moreshould use the assignment operator, I presume a typo:do_more = true if !defined? do_moreMaybe better would be
do_more = true unless defined? do_moreThat looks ok to me, but you need to test to ensure that it works correctly.
If your param is coming in from an HTML form, then the undefined case is actually a zero length string, “”. If that is your situation, then you’d want:
do_more = true if do_more == ''I’d also suggest a comment # set default