Instance Subscriptswift 6.0.1Swift

    subscript(_:)

    Accesses the code unit at the given position.

    subscript(i: String.UTF8View.Index) -> UTF8.CodeUnit { get }

    Parameters

    position

    A valid index of the view. position must be less than the view’s end index.

    The following example uses the subscript to print the value of a string’s first UTF-8 code unit.

    let greeting = "Hello, friend!"
    let i = greeting.utf8.startIndex
    print("First character's UTF-8 code unit: \(greeting.utf8[i])")
    // Prints "First character's UTF-8 code unit: 72"

    Other members in extension

    Typealiases

    Instance members

    Show obsolete interfaces (1)

    Hide obsolete interfaces