Answers for "get index filter swift"

1

get index filter swift

let items: [String] = ["A", "B", "A", "C", "A", "D"]  
print(items.enumerated().filter({ $0.element == "A" }).map({ $0.offset })) // -> [0, 2, 4]
Posted by: Guest on April-17-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language