<pedantry>
I don't know about the Python example, but the Ruby example isn't quite accurate. If Ruby's || did exactly the same as C#'s ??, the following expression:
x = false; y = true; x || y
... would have the value false (because false is non-nil), rather than its actual value: true.
In Ruby, nil and false evaluate to "false" in a Boolean context and anything else is "true". The || operator tests for "falseness", not "nilness".
</pedantry>
x = false; y = true; x || y
... would have the value false (because false is non-nil), rather than its actual value: true. In Ruby, nil and false evaluate to "false" in a Boolean context and anything else is "true". The || operator tests for "falseness", not "nilness". </pedantry>