- Code: Select all
if x
- Code: Select all
if x is not nil
but obviously,
- Code: Select all
if false
I apologize if this has been addressed before, but the search function doesn't seem to have a "find this exact phrase" feature.
Some code that exhibits this:
- Code: Select all
class NilTester
def main is shared
false_nillable as bool? = false
for condition in [true, nil, false, false_nillable]
print "Testing simple if statement with conditional [condition]:"
if condition
print "\tConditional [condition] PASSES the if statement."
else
print "\tConditional [condition] does NOT pass the if statement."
print "Testing \"is not nil\" if statement with conditional [condition]:"
if condition is not nil
print "\tConditional [condition] PASSES the if statement."
print "Conditional [condition] is of type [condition.getType].\n"
else
print "\tConditional [condition] does NOT pass the if statement.\n"
and it's results:
- Code: Select all
Testing simple if statement with conditional true:
Conditional true PASSES the if statement.
Testing "is not nil" if statement with conditional true:
Conditional true PASSES the if statement.
Conditional true is of type System.Boolean.
Testing simple if statement with conditional nil:
Conditional nil does NOT pass the if statement.
Testing "is not nil" if statement with conditional nil:
Conditional nil does NOT pass the if statement.
Testing simple if statement with conditional false:
Conditional false does NOT pass the if statement.
Testing "is not nil" if statement with conditional false:
Conditional false PASSES the if statement.
Conditional false is of type System.Boolean.
Testing simple if statement with conditional false:
Conditional false does NOT pass the if statement.
Testing "is not nil" if statement with conditional false:
Conditional false PASSES the if statement.
Conditional false is of type System.Boolean.
cobra -version tells me that I'm running 0.8.0 post-release; I just got the latest version off the svn repository.