Null-safe method access

By default, method calls are not null-safe. If the right side of a period character is a method call, Gosu throws a null-pointer exception (NPE) if the value on the left side of the period is null.

A null-safe method call does not throw an exception if the left side of the period character evaluates to null. Gosu just returns null from that expression. Using the ?. operator calls the method with null safety. This operator behaves in the same way as the null-safe period operator for properties.

See also