by @saigowthamr

How to get the first character from a string in Swift

Home » swift » How to get the first character from a string in Swift

To get the first character from a string we need to use the string.first property in swift.

Example:

let name = "polo"

if let firstChar = name.first {
    print(firstChar)
}

// Prints "p"

Swift- first property docs