typeExpression

Two operators over data type.

Figure 6.22. typeExpression

typeExpression

Table 6.4. Binary Logical Operators

 OperatorMeaning Operand TypesResult Type
instanceofIs this object of the specified typeObject instanceof TypeBoolean
asConvert this object to the specified typeObject as TypeObject (of type Type)

For example:

function toString(val : Object) : String {
   if (val instanceof String) 
      val as String 
   else 
      "Not a String"
}

This example function uses instanceof to check if the input is a String, and if it is, it changes the type of the expression to String using the as operator.