Using class members

Objects have members consisting of functions and data (methods andinstance variables, respectively). When you call a method, you _invoke_it on an object: the method has access to that object’s functions anddata.

Use a dot (.) to refer to an instance variable or method:

1. var p = Point(2, 2);

3. // Set the value of the instance variable y.
4. p.y = 3;

6. // Get the value of y.
7. assert(p.y == 3);

9. // Invoke distanceTo() on p.
10. num distance = p.distanceTo(Point(4, 4));

Use ?. instead of . to avoid an exceptionwhen the leftmost operand is null:

1. // If p is non-null, set its y value to 4.
2. p?.y = 4;