The selection of the special operators in this chapter was made according to purely subjective criteria. This is because, for example, the operations increment and decrement in gambas are counted as arithmetic functions that change the value of a variable to the nearest one. You already got to know this view in chapter 8.2 of the arithmetic operators MOD and DIV. So you could consider the functions INC and DEC as unary operators:
|INC numVariable||The value of the numeric variable is increased by 1. Analogous would be the calculation numVariable = numVariable +1 or numVariable += 1|
|DEC numVariable||The value of the numeric variable is decreased by 1. Analogous would be the calculation numVariable = numVariable -1 or numVariable -= 1|
|Expression IS Class||Returns TRUE if an object is an instance of a class or its descendants. Expression is any expression that returns an object reference and Class is a class name.|
|Expression NOT IS Class||Returns TRUE if an object is not an instance of a class or its descendants.|
Table 8.6.1: Special operators
PRINT ["Gambas", "rules!"] IS String True DIM myTextBox AS NEW TextBox(ME) PRINT myTextBox IS Control True PRINT ["Gambas", "rules!"] IS Collection False PRINT ["Gambas", "rules!"] NOT IS Collection True
The !-operator is a special operator for certain container objects that allow access to their elements using a string. Examples of such classes are Collection and Result, but also graphical controls like ListView.
The key string is written after the! operator, so that 'hCollection!FirstName' is equivalent to 'hCollection[“FirstName”]'. The return value is the value of the element with the key “FirstName”.
sCurrent.FirstName = hResult!FirstName sCurrent.FirstName = hResult["FirstName"] ' Alternative