Null object: Difference between revisions
→{{header|langur}}
Langurmonkey (talk | contribs) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 934:
</pre>
=={{header|GDScript}}==
Godot has a null value. Here is an example of dealing with null.
<syntaxhighlight lang="gdscript">
extends Node2D
func _ready() -> void:
var empty : Object
var not_empty = Object.new()
# Compare with null.
if empty == null:
print("empty is null")
else:
print("empty is not null")
# C-like comparation.
if not_empty:
print("not_empty is not null")
else:
print("not_empty is null")
return
</syntaxhighlight>
{{out}}
<pre>
empty is null
not_empty is not null
</pre>
=={{header|Go}}==
Line 1,163 ⟶ 1,189:
=={{header|langur}}==
Null can be compared for directly, using equality operators
<syntaxhighlight lang="langur">val .x, .y = true, null
Line 2,315 ⟶ 2,338:
It is always easy to test for nullness either by querying a variable's type or checking the value of a boolean expression involving a potentially null variable.
<syntaxhighlight lang="
var s
|