method fmt
1 | class List |
1.1 | (List) method fmt |
2 | class Range |
2.1 | (Range) method fmt |
3 | role Sequence |
3.1 | (Sequence) method fmt |
4 | class Pair |
4.1 | (Pair) method fmt |
5 | class Cool |
5.1 | (Cool) method fmt |
Documentation for method fmt
assembled from the following types:
class List
From List
(List) method fmt
Defined as:
method fmt( = '%s', = ' ' --> Str)
Returns a string where each element in the list has been formatted according to $format
and where each element is separated by $separator
.
For more information about formats strings, see sprintf.
my = 8..11;say .fmt('%03d', ','); # OUTPUT: «008,009,010,011»
class Range
From Range
(Range) method fmt
Defined as
method fmt(|c)
Returns a string where min
and max
in the Range have been formatted according to |c
.
For more information about formats strings, see sprintf.
say (1..2).fmt("Element: %d", ",") # OUTPUT: «Element: 1,Element: 2»
role Sequence
From Sequence
(Sequence) method fmt
method fmt( = '%s', = ' ' --> Str)
class Pair
From Pair
(Pair) method fmt
Defined as:
multi method fmt(Pair: Str --> Str)
Takes a format string, and returns a string the key and value parts of the Pair
formatted. Here's an example:
my = :Earth(1);say .fmt("%s is %.3f AU away from the sun")# OUTPUT: «Earth is 1.000 AU away from the sun»
For more about format strings, see sprintf.
class Cool
From Cool
(Cool) method fmt
Defined as:
method fmt( = '%s')
Uses $format
to return a formatted representation of the invocant; equivalent to calling sprintf with $format
as format and the invocant as the second argument. The $format
will be coerced to Stringy and defaults to '%s'
.
For more information about formats strings, see sprintf.
say 11.fmt('This Int equals %03d'); # OUTPUT: «This Int equals 011»say '16'.fmt('Hexadecimal %x'); # OUTPUT: «Hexadecimal 10»