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
string::chomp("hello\n")
This function is useful for ensuring that strings do not end with unexpected newline characters.