chop
ErrorsCollection

chop

Synthesised documentation from type/Allomorph type/Cool type/Str

From type/Allomorph

See Original text in context

method chop(Allomorph:D: |c)

Calls Str.chop on the invocant's Str value.

From type/Cool

See Original text in context

sub chop(Str(Cool))
method chop()

Coerces the invocant (or in sub form, its argument) to Str, and returns it with the last character removed.

say 'raku'.chop;                        # OUTPUT: «rak␤»

From type/Str

See Original text in context

multi method chop(Str:D:)
multi method chop(Str:D: Int() $chopping)

Returns the string with $chopping characters removed from the end.

say "Whateverable".chop(3.6);  # OUTPUT: «Whatevera␤» 
my $string= "Whateverable";
say $string.chop("3");         # OUTPUT: «Whatevera␤»

The $chopping positional is converted to Int before being applied to the string.