Documentation for routine --
assembled from the following pages:
Language documentation: Operators §
From Operators
(Operators) prefix -- §
multi sub prefix:<-->( is rw) is assoc<non>
Decrements its argument by one and returns the updated value.
my = 3;say --; # OUTPUT: «2» say ; # OUTPUT: «2»
It works by calling the pred method (for predecessor) on its argument, which gives custom types the freedom to implement their own decrement semantics.
Language documentation: Operators §
From Operators
(Operators) postfix -- §
multi sub postfix:<-->( is rw) is assoc<non>
Decrements its argument by one and returns the original value.
my = 3;say --; # OUTPUT: «3» say ; # OUTPUT: «2»
It works by calling the pred method (for predecessor) on its argument, which gives custom types the freedom to implement their own decrement semantics.
Note that this does not necessarily return its argument;e.g., for undefined values, it returns 0:
my ;say --; # OUTPUT: «0» say ; # OUTPUT: «-1»
Decrement on Str will decrement the number part of a string and assign the resulting string to the container. A is rw
-container is required. Crossing 0 is prohibited and throws X::AdHoc
.
my = "somefile-003.txt";say -- for 1..3;# OUTPUT: «somefile-003.txtsomefile-002.txtsomefile-001.txt»