Methods by type
succ & pred — increment
FullThe next and previous value — numbers step by one, strings increment magically.
.succ returns the successor (next value) and .pred the predecessor. For numbers that's ±1; for strings it's Raku's magic increment, which carries across letters and digits the way an odometer would.
Numbers #
.succ/.pred step by one; the ++/-- operators are the mutating shorthands.
say 5.succ; say 5.pred; my $x = 10; $x++; say $x;
Output
6
4
11String increment #
.succ on a string increments the rightmost alphanumeric run, carrying into the next position and preserving case and width.
say "az".succ; say "Az".succ; say "a9".succ; say "zz".succ;
Output
ba
Ba
b0
aaa"zz" carries all the way and grows to "aaa", just like 99 → 100.
Notes #
- This is what drives string ranges:
"a".."e"walks the.succsequence. - The carry propagates through the whole trailing alphanumeric run:
"a9".succis"b0"(the9wraps to0and carries into thea), the same odometer logic as numbers. ++/--use.succ/.predunder the hood, so they work on any type that defines them, not just numbers.