Skip to content

Instantly share code, notes, and snippets.

@Th3nion
Created September 13, 2017 12:08
Show Gist options
  • Save Th3nion/15d51fb4487e789ad43af84eb2414793 to your computer and use it in GitHub Desktop.
Save Th3nion/15d51fb4487e789ad43af84eb2414793 to your computer and use it in GitHub Desktop.
//
// 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