routine succ
1 | enum Bool |
1.1 | (Bool) routine succ |
2 | class Date |
2.1 | (Date) method succ |
3 | role Enumeration |
3.1 | (Enumeration) method succ |
4 | class Str |
4.1 | (Str) method succ |
5 | class Numeric |
5.1 | (Numeric) method succ |
6 | class IO::Path |
6.1 | (IO::Path) method succ |
Documentation for routine succ
assembled from the following types:
enum Bool
From Bool
(Bool) routine succ
method succ(--> Bool)
Returns True
.
say True.succ; # OUTPUT: «True»say False.succ; # OUTPUT: «True»
succ
is short for "successor"; it returns the next enum value. Bool is a special enum with only two values, False
and True
. When sorted, False
comes first, so True
is its successor. And since True
is the "highest" Bool enum value, its own successor is also True
.
class Date
From Date
(Date) method succ
Defined as:
method succ(Date: --> Date)
Returns a Date
of the following day. "succ" is short for "successor".
say Date.new("2016-02-28").succ; # OUTPUT: «2016-02-29»
role Enumeration
From Enumeration
(Enumeration) method succ
Defined as:
method succ(::?CLASS:)
say Oðin.succ; # OUTPUT: «Freija»
class Str
From Str
(Str) method succ
method succ(Str --> Str)
Returns the string incremented by one.
String increment is "magical". It searches for the last alphanumeric sequence that is not preceded by a dot, and increments it.
'12.34'.succ; # RESULT: «13.34»'img001.png'.succ; # RESULT: «img002.png»
The actual increment step works by mapping the last alphanumeric character to a character range it belongs to, and choosing the next character in that range, carrying to the previous letter on overflow.
'aa'.succ; # RESULT: «ab»'az'.succ; # RESULT: «ba»'109'.succ; # RESULT: «110»'α'.succ; # RESULT: «β»'a9'.succ; # RESULT: «b0»
String increment is Unicode-aware, and generally works for scripts where a character can be uniquely classified as belonging to one range of characters.
class Numeric
From Numeric
(Numeric) method succ
method succ(Numeric:)
Returns the number incremented by one (successor).
class IO::Path
From IO::Path
(IO::Path) method succ
Defined as:
method succ(IO::Path: --> IO::Path)
Returns a new IO::Path constructed from the invocant, with .basename
changed by calling Str.succ
on it.
"foo/file02.txt".IO.succ.say; # OUTPUT: «"foo/file03.txt".IO»