In role Systemic§
See primary documentation in context for method Str.
methodStr
Instance method returning the name of the object.
say$*RAKU.Str; # OUTPUT: «Raku»
In Code§
See primary documentation in context for method Str.
multimethodStr(Code:D: --> Str:D)
Will output the method name, but also produce a warning. Use .raku
or .gist
instead.
sub marine() { } say ~&marine; # OUTPUT: «Sub object coerced to string (please use .gist or .raku to do that)marine» say&marine.Str; # OUTPUT: «Sub object coerced to string (please use .gist or .raku to do that)marine» say&marine.raku; # OUTPUT: «sub marine { #`(Sub|94280758332168) ... }»
In Num§
See primary documentation in context for method Str.
methodStr(Int:D)
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»
In Int§
See primary documentation in context for method Str.
multimethodStr(Int:D) multimethodStr(Int:D,:$superscript) multimethodStr(Int:D,:$subscript)
Returns a string representation of the number.
say 42.Str; # OUTPUT: «42»
Cool
being a parent class of Int
, an explicit call to the Int.Str
method is seldom needed, unless you want the string to be returned in superscript or subscript.
say 42.Str(:superscript); # OUTPUT: «⁴²» say 42.Str(:subscript); # OUTPUT: «₄₂»
The :superscript
and :subscript
named arguments are available as of the 2023.05 Rakudo compiler release.
In Date§
See primary documentation in context for method Str.
multimethodStr(Date:D: --> Str:D)
Returns a string representation of the invocant, as specified by the formatter. If no formatter was specified, an (ISO 8601) date will be returned.
sayDate.new('2015-12-24').Str; # OUTPUT: «2015-12-24» my$fmt= { sprintf"%02d/%02d/%04d", .month, .day, .year }; sayDate.new('2015-12-24',formatter=>$fmt).Str; # OUTPUT: «12/24/2015»
In Label§
See primary documentation in context for method Str.
Converts to a string including the name, file and line it's been defined in.
In Nil§
See primary documentation in context for method Str.
methodStr()
Warns the user that they tried to stringify a Nil
.
In Mu§
See primary documentation in context for method Str.
multimethodStr(-->Str)
Returns a string representation of the invocant, intended to be machine readable. Method Str
warns on type objects, and produces the empty string.
sayMu.Str; # Use of uninitialized value of type Mu in string context. my@foo= [2,3,1]; say@foo.Str# OUTPUT: «2 3 1»
In List§
See primary documentation in context for method Str.
methodStr(List:D: --> Str:D)
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»
In IO::Special§
See primary documentation in context for method Str.
methodStr(IO::Special:D:)
This returns '<STDIN>'
, '<STDOUT>'
, or '<STDERR>'
as appropriate.
In role Real§
See primary documentation in context for method Str.
multimethodStr(Real:D:)
Calls the Bridge
method on the invocant and then the Str
method on its return value.
In Thread§
See primary documentation in context for method Str.
methodStr(Thread:D: --> Str:D)
Returns a string which contains the invocants thread id and name.
my$t=Thread.new(code=> { for 1..5 ->$v { say$v }},name=>'calc thread'); say$t.Str; # OUTPUT: «Thread<3>(calc thread)»
In RakuAST::Doc::Block§
See primary documentation in context for method Str.
put$block; # bar
Returns the string for the paragraphs of the block, with any markup also stringified.
In Match§
See primary documentation in context for method Str.
methodStr(Match:D: --> Str:D)
Returns the matched text.
"abc123def"~~/\d+/; say $/.Str; # OUTPUT: «123»
In Version§
See primary documentation in context for method Str.
methodStr(Version:D: --> Str:D)
Returns a string representation of the invocant.
my$v1= v1.0.1; my$v2=Version.new('1.0.1'); say$v1.Str; # OUTPUT: «1.0.1» say$v2.Str; # OUTPUT: «1.0.1»
In Allomorph§
See primary documentation in context for method Str.
methodStr(Allomorph:D:)
Returns the Str
value of the invocant.
In RakuAST::Doc::Paragraph§
See primary documentation in context for method Str.
put$paragraph; # Text before B<and> after markup
Returns the string for the paragraph, with any markup stringified.
In IO::Handle§
See primary documentation in context for method Str.
Returns the value of .path
, coerced to Str
.
say"foo".IO.open.Str; # OUTPUT: «foo»
In Junction§
See primary documentation in context for method Str.
multimethodStr(Junction:D:)
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.
In IO::Path§
See primary documentation in context for method Str.
methodStr(IO::Path:D: -->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 .absolute
or .relative
methods.
In role Sequence§
See primary documentation in context for method Str.
multimethodStr(::?CLASS:D:)
Stringifies the cached sequence.
In ForeignCode§
See primary documentation in context for method Str.
methodStr( ForeignCode:D: )
Returns the name of the code by calling name
.
In IO::CatHandle§
See primary documentation in context for method Str.
methodStr(IO::CatHandle:D: --> Str:D)
Calls .Str
on the currently active source handle and returns the result. If the source handle queue has been exhausted, returns an implementation-defined string ('<closed IO::CatHandle>'
in Rakudo).
In Backtrace§
See primary documentation in context for method Str.
multimethodStr(Backtrace:D:)
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=Backtrace.new; say$backtrace.Str;
In Pair§
See primary documentation in context for method Str.
multimethodStr(Pair:D: --> Str:D)
Returns a string representation of the invocant formatted as key ~ \t ~ value.
my$b= eggs => 3; say$b.Str; # OUTPUT: «eggs 3»
In RakuAST::Doc::Markup§
See primary documentation in context for method Str.
put$markup; # B<and>
Returns the string for the markup object, with any embedded markup also stringified.
In StrDistance§
See primary documentation in context for method Str.
multimethodStr(StrDistance:D: -->Str)
Returns an after
string value.
my$str-dist= ($str~~ tr/old/new/); say$str-dist.Str; # OUTPUT: «fnew» say~$str-dist; # OUTPUT: «fnew»
In role Blob§
See primary documentation in context for method Str.
multimethodStr(Blob:D:)
Throws X::Buf::AsStr
with Str
as payload. In order to convert to a Str
you need to use .decode
.
In DateTime§
See primary documentation in context for method Str.
methodStr(DateTime:D: --> Str:D)
Returns a string representation of the invocant, as done by the formatter. If no formatter was specified, an ISO 8601 timestamp will be returned.
sayDateTime.new('2015-12-24T12:23:00+0200').Str; # OUTPUT: «2015-12-24T12:23:00+02:00»