pred
ErrorsCollection

pred

Synthesised documentation from type/IO/Path type/Enumeration type/Date type/Bool type/Numeric type/Allomorph type/Str

From type/IO/Path

See Original text in context

method pred(IO::Path:D: --> IO::Path:D)

Returns a new IO::Path constructed from the invocant, with basename changed by calling Str.pred on it.

"foo/file02.txt".IO.pred.say# OUTPUT: «"foo/file01.txt".IO␤»

From type/Enumeration

See Original text in context

method pred(::?CLASS:D:)
say Freija.pred;  # OUTPUT: «Oðin␤» 

From type/Date

See Original text in context

method pred(Date:D: --> Date:D)

Returns a Date of the previous day. "pred" is short for "predecessor".

say Date.new("2016-01-01").pred;   # OUTPUT: «2015-12-31␤»

From type/Bool

See Original text in context

method pred(--> Bool:D)

Returns False.

say True.pred;                                    # OUTPUT: «False␤» 
say False.pred;                                   # OUTPUT: «False␤»

pred is short for "predecessor"; it returns the previous enum value. Bool is a special enum with only two values, False and True. When sorted, False comes first, so False is the predecessor to True. And since False is the "lowest" Bool enum value, its own predecessor is also False.

From type/Numeric

See Original text in context

method pred(Numeric:D:)

Returns the number decremented by one (predecessor).

From type/Allomorph

See Original text in context

method pred(Allomorph:D:)

Calls Numeric.pred on the invocant's numeric value.

From type/Str

See Original text in context

method pred(Str:D: --> Str:D)

Returns the string decremented by one.

String decrementing is "magical" just like string increment (see succ). It fails on underflow

'b0'.pred;           # OUTPUT: «a9» 
'a0'.pred;           # OUTPUT: Failure 
'img002.png'.pred;   # OUTPUT: «img001.png»