Reflection module

enum_name_to_value

procedureSource

The member of the enum T called name, and whether there is one.

enum_name_to_value :: ($T: Type, name: string) -> (T, bool)

Parameters

$T: Type
name: string

Returns

T
bool
Example↗
Color :: enum { RED; GREEN; BLUE; }
value, found := enum_name_to_value(Color, "GREEN");
assert(found && value == .GREEN);
_, found = enum_name_to_value(Color, "PINK");
assert(!found);

See also