Posts

Showing posts from April 19, 2019

Creating an enum from its name not value

Image
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box; } 7 Given the enumeration enum NATO (:alpha<A>, :bravo<B>, :charlie<C>, :delta<D>); it's possible to easily set a variable by literally typing one of the names, or by passing one of the values to the enum object: my $a = alpha; my $b = NATO('B'); say $a; # ↪︎ alpha say $b; # ↪︎ bravo say $a.value; # ↪︎ A say $b.value; # ↪︎ B Besides using EVAL and given a Str that corresponds to one of the enums, how could I create $c to be an enum value equivalent to charlie ? my $x = 'charlie'; my $c = ... enums perl6