Dot .
The dot operator has multiple functions.
Field Access
bool a = b.myField;
Static Cast
int a = pi.int;
Dynamic Cast
MyClass a = object.MyClass;
Enumeration Access
fontWeight a = fontWeight.bold;
Enumeration Test
fontWeight a; bool b = a.bold;
Null Safe Field Access .?
bool a = b.?myField;
Returns the field value if b is not null, and null otherwise (or a zero memory value if the field is not a class). Access is safe for subsequent dot-accesses in the same expression as well, so these two are actually identical:
int x = a.?b.?c.?d.?e; int y = a.?b.c.d.e;
Type Conversion .:
MyClass a = object.:MyClass; callback = fn.:function(Control):int
A dynamic cast can always be done with the .: operator. The dot operator overloads to dynamic cast as well unless there are other prioritized overloads (package reference, enum value or enum test, field access).
Indexed Access []
Object z = sequence[3];
Comments
0 comments
Please sign in to leave a comment.