class haxe.EnumValueTools
import haxe.EnumTools;
Class Fields
static function equals<T>(a:T, b:T): Bool
Recursively compares two enum instances a
and b
by value.
Unlike a == b
, this function performs a deep equality check on the
arguments of the constructors, if exists.
If a
or b
are null, the result is unspecified.
static function getIndex(e:EnumValue): Int
Returns the index of enum instance e
.
This corresponds to the original syntactic position of e
. The index of
the first declared constructor is 0, the next one is 1 etc.
If e
is null, the result is unspecified.
static function getName(e:EnumValue): String
Returns the constructor name of enum instance e
.
The result String does not contain any constructor arguments.
If e
is null, the result is unspecified.
static function getParameters(e:EnumValue): Array<Dynamic>
Returns a list of the constructor arguments of enum instance e
.
If e
has no arguments, the result is [].
Otherwise the result are the values that were used as arguments to e
,
in the order of their declaration.
If e
is null, the result is unspecified.
static function match(e:EnumValue, pattern:Dynamic): Bool
Matches enum instance e
against pattern pattern
, returning true if
matching succeeded and false otherwise.
Example usage:
if (e.match(pattern)) {
// codeIfTrue
} else {
// codeIfFalse
}
This is equivalent to the following code:
switch (e) {
case pattern:
// codeIfTrue
case _:
// codeIfFalse
}
This method is implemented in the compiler. This definition exists only for documentation.