Answers for "swift string element at index"

1

index of string in array swift

let arr = ["a","b","c","a"]

let indexOfA = arr.firstIndex(of: "a") // 0
let indexOfB = arr.lastIndex(of: "a") // 3
Posted by: Guest on January-30-2020
0

index string swift

let string = "Hello, World!"
let index = string.index(string.startIndex, offsetBy: 3)

print(string[index]) // Prints "l"

// This can be done in one line too:
print(string[string.index(string.startIndex, offsetBy: 3)])
Posted by: Guest on December-23-2020

Code answers related to "swift string element at index"

Code answers related to "Swift"

Browse Popular Code Answers by Language