The provided condition is unnecessary and can be substituted with ||
operator. Since this operator implicitly checks if the first operand is truthy, there is no need to explicitly check it with a condition.
a = b ? b : c
ary << if foo
foo
else
bar
end
if b
b
else
raise 'foo'
end
# this will return a nil value if bar is falsy
bar if bar
if foo
bar(foo)
else
bar({})
end
a = b || c
b || c
if b
b
elsif cond
c
end
b || raise('foo')
ary << (foo || bar)
# Checking for a hash key before returning it is allowed
if @cache[key]
@cache[key]
else
@cache[key] = heavy_load[key]
end
bar(foo || {})