Null object: Difference between revisions

Added more information.
No edit summary
(Added more information.)
Line 1,403:
{.experimental: "notnil".}
let ns: pointer not nil = nil # Compile time error</lang>
 
The value "nil" can be used for pointers, references (i.e. pointers managed by the garbage collector) and procedures. It was also used for strings and sequences, but this is no longer the case (option <code>--nilseqs:on</code> allows to retrieve the old behavior).
 
Testing if a pointer “p” is <code>nil</code> can be done either by using <code>==</code> or using the procedure <code>isNil</code>.
 
<lang Nim>var p: ptr int
if p == nil: echo "it is nil"
if p != nil: echo "it is not nil"
if p.isNil: echo "it is nil"</lang>
 
=={{header|Oberon-2}}==
Anonymous user