subscript(_:)
Accesses the code unit at the given position.
Declaration
subscript(i: String.UTF8View.Index) -> UTF8.CodeUnit { get }Overview
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"