Undefined values: Difference between revisions

Added Wren
m (→‎{{header|Raku}}: Fix links and comments: Perl 6 --> Raku)
(Added Wren)
Line 1,410:
<pre>VAR1
Not set.</pre>
 
=={{header|Wren}}==
The closest Wren has to an 'undefined' value is '''null''' though, technically, this is the only instance of the Null class.
 
Wren is dynamically typed and so ''null'' can be assigned to any variable.
 
In practice is it used to indicate the absence of a value. So, a function or method which doesn't otherwise return anything returns ''null'' and, if a map doesn't contain a key, an attempted look-up using that key returns ''null''.
 
If a variable is simply declared but not assigned a value, then its value is ''null''.
 
In conditional expressions, ''null'' as well as the Boolean value ''false'' are considered to be 'false'. All other values (including zero) are considered to be 'true'.
<lang ecmascript>var f = Fn.new {
System.print("'f' called.") // note no return value
}
 
var res = f.call()
System.print("The value returned by 'f' is %(res).")
 
var m = {} // empty map
System.print("m[1] is %(m[1]).")
 
var u // declared but not assigned a value
System.print("u is %(u).")
 
var v = null // explicitly assigned null
if (!v) System.print("v is %(v).")</lang>
 
{{out}}
<pre>
'f' called.
The value returned by 'f' is null.
m[1] is null.
u is null.
v is null.
</pre>
 
=={{header|zkl}}==
9,483

edits