This class provides advanced methods on enum values. It is ideally used with using EnumValueTools and then acts as an extension to the EnumValue types.

If the first argument to any of the methods is null, the result is unspecified.

Static methods

staticinlineequals<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 there are any).

If a or b are null, the result is unspecified.

staticinlinegetIndex (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.

staticinlinegetName (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.

staticinlinegetParameters (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.

staticmatch (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.