The OpenD Programming Language

chop

Returns str without its last character, if there is one. If str ends with "\r\n", then both are removed. If str is empty, then it is returned unchanged.

Range
chop
(
Range
)
(
Range str
)
if (
(
isBidirectionalRange!Range &&
||
)
&&
)

Parameters

str Range

string (must be valid UTF)

Return Value

Type: Range

slice of str

Examples

assert(chop("hello world") == "hello worl");
assert(chop("hello world\n") == "hello world");
assert(chop("hello world\r") == "hello world");
assert(chop("hello world\n\r") == "hello world\n");
assert(chop("hello world\r\n") == "hello world");
assert(chop("Walter Bright") == "Walter Brigh");
assert(chop("") == "");

Meta