Skip to content

String Chomp

The string::chomp function removes the trailing newline character from a string, if one exists.

Syntax

string::chomp(<string>)

Parameters

  • string: The input string to modify.

Returns

  • String: The input string without a trailing newline character.

Example

Try it out below!
string::chomp("hello\n")

This function is useful for ensuring that strings do not end with unexpected newline characters.