In Swift, is there a clever way of using the higher order methods on Array to return the 5 first objects? The obj-c way of doing it was saving an index, and for-loop throug
I slightly changed Markus' answer to update it for the latest Swift version, as var inside your method declaration is no longer supported:
var
extension Array { func takeElements(elementCount: Int) -> Array { if (elementCount > count) { return Array(self[0..