5.24 type check

since Haxe 3.1.0

It is possible to employ compile-time type checks using the following syntax:

(expr : type)

The parentheses are mandatory. Unlike safe casts this construct has no run-time impact. It has two compile-time implications:

  1. Top-down inference is used to type expr with type type.
  2. The resulting typed expression is unified with type type.

This has the usual effect of both operations such as the given type being used as expected type when performing unqualified identifier resolution and the unification checking for abstract casts.


Take the Haxe Survey!