Hi,
Trying to use an enum. Can't easily find out how to use them. Looked in
both design documents and in the language documents page.
I can't seem to get the examples in the design documents to work. So I
seem to be missing something.
I got the following to work, and I thought enum was supposed to be a
syntatic sugar for this
...
my %SortOrder = <module simple recursive> Z[=>] 1..2;
...
# $sort = 'simple';
my @ordered = @array-of-three.sort( *.[ %SortOrder{$sort} ] );
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) ] );
...
}
I also tried
my SortOrder $s = $sort; # this fails
...
my @ordered = @array-of-three.sort( *.[ $s.value ] );