Operators: Introduction

Hack supports most of the PHP operators, including the recently introduced null coalescing (??) operator.

The current exception of support is the "spaceship" (<=>) operator; you can use it in your Hack code since HHVM supports it, but it will not be type checked.

Hack also introduces a few new operators beyond those which exists in PHP.

==> (Lambda operator)

Allows for a more concise representation of PHP closures with the benefit of capturing variables from the enclosing function body implicitly.

?-> (null-safe operator)

Allows for method and property calls without explicit checks to ensure that the object being referenced is non-null.

->: (XHP attribute access operator)

Allows for accessing XHP attributes without explicitly having to call getAttribute() on the XHP object.

|> (Pipe operator)

Allows for a fluid, concise syntax for chaining expressions.