Anonymous user
Null object: Difference between revisions
Add Lily example
(Added Axe) |
(Add Lily example) |
||
Line 623:
#y->type == 'null'
//true</lang>
=={{header|Lily}}==
Lily doesn't provide a built-in nothing type, but allows one to be created using enum class:
<lang Lily>enum class Option[A] {
Some(A)
None
}
# Only variables of class Option can be assigned to None.
# Type: Option[integer]
var v = Some(10)
# Valid: v is an Option, and any Option can be assigned to None
v = None
# Invalid! v is an Option[integer], not just a plain integer.
v = 10
# Type: integer
var w = 10
# Invalid! Likewise, w is an integer, not an Option.
w = None</lang>
=={{header|Logo}}==
|