Created
September 13, 2017 12:08
-
-
Save Th3nion/15d51fb4487e789ad43af84eb2414793 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Array+Extension.swift | |
// | |
// | |
import Foundation | |
extension Array where Element: Equatable { | |
mutating func remove(object: Element) { | |
if let index = index(of: object) { | |
remove(at: index) | |
} | |
} | |
} | |
extension Array { | |
func chunksArray(_ chunkSize: Int) -> [[Element]] { | |
return stride(from: 0, to: self.count, by: chunkSize).map { | |
Array(self[$0..<Swift.min($0 + chunkSize, self.count)]) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment