None Object
| sections in this chapter: |
|---|
| [ None ] None? » |
| [ None ] string » |
| [ None ] else: [ Object ] » |
| [ None ] number » |
| [ None ] boolean » |
The None object represents emptiness, or better still, the absence of information. On occasion, you will receive this object as an answer to a message, in case of the result being nothing. The most essential question you could ask the None object is: None?. The answer will always read True.
Out write: None None?.
result:
True
Any object other than None will reply with False. The above code fragment may seem a bit philosophical, yet the None object certainly has extremely practical applications. For example, you will receive the None object as an answer in case you ask for a sequence element that does not exist. You could also use the None object if you like to declare a variable, but do not want to specify a value yet. Instead, you just assign the special value None. In Xoscript it is not allowed to declare a variable without value, such as:
>> value.
Instead, you have to write the following:
>> value := None.
[ None ] None?
Example:
>> x := None.
Out write: x None?, stop.
Result:
[ None ] string
Example:
>> x := None.
Out write: x string, stop.
Result:
[ None ] else: [ Object ]
Example:
>> x := None.
Out write: (x else: 123), stop.
Result:
[ None ] number
Example:
>> x := None.
Out write: x number, stop.
Result:
[ None ] boolean
Example:
>> x := None.
Out write: x bool, stop.
Result: