If you don't want to add || false
, but you don't want nil
to be returned, you can do the following:
def some_method
!!(first_var || second_var)
end
This way, if the return value of (first_var || second_var)
is nil
a false
will be returned:
!!true
# => true
!!false
# => false
!!nil
# => false