3 ms·
You can also do: NULL = Object.new.freeze def foo(bar = NULL) if bar.equal?(NULL) # default value end end
by judofyr 14y ago
You can also do:
NULL = Object.new.freeze
def foo(bar = NULL)
if bar.equal?(NULL)
# default value
end
end
- Xylakant 14y agoright, that would work to. I'd still prefer the original solution since it avoids creating a magic constant.