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
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
string index in swift
extension String {
subscript(_ n: Int) -> Character {
return self[self.index(self.startIndex, offsetBy: n)]
}
}
let str = "Hello World"
print(str[0]) // H
print(str[4]) // o
print(str[6]) // w
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us