Swift 5 Get First Character Of String

[Solved] Swift 5 Get First Character Of String | Swift - Code Explorer | yomemimo.com
Question : swift 5 get first character of string

Answered by : wicked-wolf-kfrr7ktv1iyg

Swift 5
let str = "abcdef"
print( String(str.characters.prefix(1)) ) // output: "a"
print( String(str.characters.prefix(3)) ) // output: "abc"

Source : | Last Update : Sat, 19 Jun 21

Answers related to swift 5 get first character of string

Code Explorer Popular Question For Swift