Methods by type

succ & pred — increment

Full

The 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
11

String 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 #