The compiler is conflating Swift.Array.min(by:)
, which only takes a single argument, with the global function Swift.min(_:_:)
that you're intending to use.
Explicitly qualifying the global function by prefixing it with its module name (Swift
) resolves the issue:
extension Array {
func chunked(by chunkSize: Int) -> [[Element]] {
return stride(from: 0, to: self.count, by: chunkSize).map {
Array(self[$0 ..< Swift.min($0 + chunkSize, self.count)]) // fixed
}
}
}