sodalive-ios/SodaLive/Sources/Extensions/CollectionExtension.swift

15 lines
324 B
Swift

//
// CollectionExtension.swift
// SodaLive
//
// Created by klaus on 12/8/24.
//
extension Collection {
func mapIndexed<T>(_ transform: (Index, Element) -> T) -> [T] {
return self.enumerated().map { index, element in
transform(self.index(startIndex, offsetBy: index), element)
}
}
}