Instance Method

substring(to:)

Returns a new string containing the characters of the receiver up to, but not including, the one at a given index.

Declaration

func substring(to: Int) -> String

Parameters

anIndex

An index. The value must lie within the bounds of the receiver, or be equal to the length of the receiver.

Raises an rangeException if (anIndex - 1) lies beyond the end of the receiver.

Return Value

A new string containing the characters of the receiver up to, but not including, the one at anIndex. If anIndex is equal to the length of the string, returns a copy of the receiver.

See Also

Related Symbols

func substring(with: NSRange)

Returns a string object containing the characters of the receiver that lie within a given range.

func substring(from: Int)

Returns a new string containing the characters of the receiver from the one at a given index to the end.