See Original text in context
multi method Str(Code: --> Str)
Will output the method name, but also produce a warning. Use .raku
or .gist
instead.
sub marine()say ~;# OUTPUT: «Sub object coerced to string (please use .gist or .raku to do that)marine»say .Str;# OUTPUT: «Sub object coerced to string (please use .gist or .raku to do that)marine»say .raku; # OUTPUT: «sub marine { #`(Sub|94280758332168) ... }»
See Original text in context
method Str(Int)
Returns a string representation of the number.
say π.Str; # OUTPUT: «3.141592653589793»
Cool
being a parent class of Num
, an explicit call to the Num.Str
method is seldom needed.
say π.Str.comb == π.comb; # OUTPUT: «True»
See Original text in context
method Str()
Warns the user that they tried to stringify a Nil
.
See Original text in context
method Str( ForeignCode: )
Returns the name of the code by calling name
.
See Original text in context
method Str(IO::Path: --> Str)
Alias for IO::Path.path
. In particular, note that default stringification of an IO::Path
does NOT use the value of $.CWD
attribute. To stringify while retaining full path information use IO::Path.absolute
or IO::Path.relative
methods.
See Original text in context
multi method Str(Blob:)
Throws X::Buf::AsStr
with Str
as payload. In order to convert to a Str
you need to use .decode
.
See Original text in context
method Str(Match: --> Str)
Returns the matched text.
"abc123def" ~~ /\d+/;say $/.Str; # OUTPUT: «123»
See Original text in context
Converts to a string including the name, file and line it's been defined in.
See Original text in context
multi method Str(--> Str)
Returns a string representation of the invocant, intended to be machine readable. Method Str
warns on type objects, and produces the empty string.
say Mu.Str; # Use of uninitialized value of type Mu in string context.my = [2,3,1];say .Str # OUTPUT: «2 3 1»
See Original text in context
multi method Str(Date: --> Str)
Returns a string representation of the invocant, as specified by the formatter. If no formatter was specified, an (ISO 8601) date will be returned.
say Date.new('2015-12-24').Str; # OUTPUT: «2015-12-24»my = ;say Date.new('2015-12-24', formatter => ).Str; # OUTPUT: «12/24/2015»
See Original text in context
multi method Str(::?CLASS:)
Stringifies the cached sequence.
See Original text in context
multi method Str(StrDistance: --> Str)
Returns an after
string value.
my = ( ~~ tr/old/new/);say .Str; # OUTPUT: «fnew»say ~; # OUTPUT: «fnew»
See Original text in context
method Str(DateTime: --> Str)
Returns a string representation of the invocant, as done by the formatter. If no formatter was specified, an ISO 8601 timestamp will be returned.
say DateTime.new('2015-12-24T12:23:00+0200').Str;# OUTPUT: «2015-12-24T12:23:00+02:00»
See Original text in context
method Str(Thread: --> Str)
Returns a string which contains the invocants id and name.
my = Thread.new(code => , name => 'calc thread');say .Str; # OUTPUT: «Thread<3>(calc thread)»
See Original text in context
multi method Str(Backtrace:)
Returns a concise string representation of the backtrace, omitting routines marked as is hidden-from-backtrace
, and at the discretion of the implementation, also some routines from the setting.
my = Backtrace.new;say .Str;
See Original text in context
Returns the value of .path
, coerced to Str.
say "foo".IO.open.Str; # OUTPUT: «foo»
See Original text in context
method Str
Instance method returning the name of the object.
say .Str; # OUTPUT: «Raku»
See Original text in context
method Str(IO::Special:)
This returns '<STDIN>'
, '<STDOUT>'
, or '<STDERR>'
as appropriate.
See Original text in context
multi method Str(Real:)
Calls the Bridge
method on the invocant and then the Str
method on its return value.
See Original text in context
method Str(Allomorph:)
Returns the Str
value of the invocant.
See Original text in context
multi method Str(Pair: --> Str)
Returns a string representation of the invocant formatted as key ~ \t ~ value.
my = eggs => 3;say .Str; # OUTPUT: «eggs 3»
See Original text in context
method Str(IO::CatHandle: --> Str)
Calls .Str
on the currently active source handle and returns the result. If the source handle queue may get exhausted, returns an implementation-defined string ('<closed IO::CatHandle>'
in Rakudo).
See Original text in context
method Str(List: --> Str)
Stringifies the elements of the list and joins them with spaces (same as .join(' ')
).
say (1,2,3,4,5).Str; # OUTPUT: «1 2 3 4 5»
See Original text in context
multi method Str(Junction:)
Autothreads the .Str
method over its elements and returns results as a Junction. Output methods that use .Str
method (print and put) are special-cased to autothread junctions, despite being able to accept a Mu type.
See Original text in context
method Str(Version: --> Str)
Returns a string representation of the invocant.
my = v1.0.1;my = Version.new('1.0.1');say .Str; # OUTPUT: «1.0.1»say .Str; # OUTPUT: «1.0.1»