Null object: Difference between revisions

added swift
(added swift)
Line 1,079:
<lang sml>case v of NONE => "unbound value"
| SOME _ => "bounded value"</lang>
 
=={{header|Swift}}==
The closest thing in Swift are optional types.
<lang swift>var opt : Int? = nil // use "nil" to represent no value
opt = 5 // or simply assign a value to the optional type</lang>
To deconstruct it, use <code>if let</code>:
<lang swift>if let v = opt {
println("There is some value: \(v)")
} else {
println("There is no value")
}</lang>
 
=={{header|Tcl}}==
Anonymous user