Null object: Difference between revisions

Content added Content deleted
Line 1,193: Line 1,193:
Null can be compared for directly, using equality operators. Operators ending with a ? mark propagate null. A null in an expression test is a non-truthy result.
Null can be compared for directly, using equality operators. Operators ending with a ? mark propagate null. A null in an expression test is a non-truthy result.


<syntaxhighlight lang="langur">val .x, .y = true, null
<syntaxhighlight lang="langur">
var x, y = true, null


writeln .x == null
writeln x == null
writeln .y == null
writeln y == null
writeln .x ==? null
writeln x ==? null
writeln .y ==? null
writeln y ==? null


# null not a "truthy" result
# null not a "truthy" result
writeln if(null: 0; 1)</syntaxhighlight>
writeln if(null: 0; 1)
</syntaxhighlight>


{{out}}
{{out}}