In Allomorph§

See primary documentation in context for method chop.

method chop(Allomorph:D: |c)

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

In Str§

See primary documentation in context for routine chop.

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

Returns the string with $n characters removed from the end. The original string is left unchanged. The $n positional is converted to Int beforehand.

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

Calls without an argument remove just one character. If the string contains fewer characters than are to be chopped, the result is the empty string.

In Cool§

See primary documentation in context for routine chop.

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␤»