In Cool§
See primary documentation in context for routine chomp
sub chomp(Str(Cool))method chomp()
Coerces the invocant (or in sub form, its argument) to Str
, and returns it with the last character removed, if it is a logical newline.
say 'ab'.chomp.chars; # OUTPUT: «2»say "a\n".chomp.chars; # OUTPUT: «1»
In IO::CatHandle§
See primary documentation in context for method chomp
method chomp(IO::CatHandle:) is rw
Sets the invocant's $.chomp
attribute to the assigned value. All source handles, including the active one will use the provided $.chomp
value.
(my = 'foo'.IO).spurt: "A\nB\nC\n";(my = 'bar'.IO).spurt: "D\nE\n";with IO::CatHandle.new: ,
In Str§
See primary documentation in context for routine chomp
multi chomp(Str --> Str)multi method chomp(Str: --> Str)
Returns the string with a logical newline (any codepoint that has the NEWLINE
property) removed from the end.
Examples:
say chomp("abc\n"); # OUTPUT: «abc»say "def\r\n".chomp; # OUTPUT: «def» NOTE: \r\n is a single grapheme!say "foo\r".chomp; # OUTPUT: «foo»
In Allomorph§
See primary documentation in context for method chomp
method chomp(Allomorph:)
Calls Str.chomp
on the invocant's Str
value.
In IO::Handle§
See primary documentation in context for method chomp
has is rw = True
One of the attributes that can be set via .new
or open. Defaults to True
. Takes a Bool
specifying whether the line separators (as defined by .nl-in
) should be removed from content when using .get
or .lines
methods.