String

struct String

An extension to assist in retrieving substrings.

  • Retrieves the Character at index i. Called using variable_name[i].

    Declaration

    Swift

    subscript (i: Int) -> Character

    Parameters

    i

    The index of the wanted Character, as an Int.

    Return Value

    Character at index i.

  • Retrieves the Character at the specified index of a String. Called using variable_name[i].

    Declaration

    Swift

    subscript (i: Int) -> String

    Parameters

    i

    The index of the wanted Character, as an Int.

    Return Value

    The Character at index i, as a String.

  • Returns a substring from the specified range.

    Declaration

    Swift

    subscript (r: Range<Int>) -> String

    Parameters

    r

    Range of Int containing the indices of the wanted Characters in the String.

    Return Value

    The substring represented by r, as a String.