On 06/11/15 06:50, Richard Hainsworth wrote:
I'm trying to do something like the following:

sub MAIN ( Str :$sort = 'simple') {

my enum SortOrder <name simple recursive>;
my @array-of-three;
...
my @ordered = @array-of-three.sort(*.[ SortOrder($sort) ] );
...

}

Hi Richard,

SortOrder($foo) is an interface to get the enum object from its index value, i.e. the number. On the other hand, an enum also acts as a Package, so you can use package lookup syntax. This should be added to the docs.

Here's an example:

enum SortOrder <name simple recursive>; say SortOrder::{"name"}.perl
# outputs: SortOrder::name

I hope this helps!
  - Timo
  • A tutorial on ENUMs? Richard Hainsworth
    • Re: A tutorial on ENUMs? - look up enum symbol by ... Timo Paulssen

Reply via email to