Files
EeveeSpotifyReborn/Sources/EeveeSpotify/Models/Extensions/Collection+Extension.swift
2024-05-04 20:13:19 +03:00

10 lines
324 B
Swift

import Foundation
extension Collection {
func dropLast(while predicate: (Element) throws -> Bool) rethrows -> SubSequence {
guard let index = try indices.reversed().first(where: { try !predicate(self[$0]) }) else {
return self[startIndex..<startIndex]
}
return self[...index]
}
}