The net result is that you now must use
@arr[*-1]
to get the last element, you cannot get away with simply using @arr[*]
.Some may feel that this extra typing is bothersome, especially if you have a Unicode-friendly keyboard setup.
However, we can sneak our way past this problem by using a
constant
.This also works with the current release of Rakudo, so it's not quite science fiction:
constant Ω = *-1;Or, if you're feeling Cyrillic rather than Greek:
constant Ѡ = *-1;Now we can substitute our nice constant for
*-1
anywhere in the following code:my @letters = 'a'..'z';Like so:
say '→'~@letters[*-1];
→z
constant Ω = *-1;And, of course, you can do this with other things that are so tedious to type when you're dealing with maths:
my @letters = 'a'..'z';
say '→'~@letters[Ω];
→z
constant π = pi;
say '→'~π
→3.14159265358979
1 comment:
OMG!!! I can see that you perl guys still dont understand anything about a clean syntax. :)
Post a Comment