The OpenD Programming Language

commonPrefix

Returns the common prefix of two ranges.

Parameters

r1 R1

A forward range of elements.

r2 R2

An input range of elements.

Return Value

Type: auto

A slice of r1 which contains the characters that both ranges start with, if the first argument is a string; otherwise, the same as the result of takeExactly(r1, n), where n is the number of elements in the common prefix of both ranges.

Examples

assert(commonPrefix("hello, world", "hello, there") == "hello, ");

See Also

Meta