Skip to content

Instantly share code, notes, and snippets.

@romainmenke
Last active September 23, 2015 05:16
Show Gist options
  • Save romainmenke/267125e39598988c4df0 to your computer and use it in GitHub Desktop.
Save romainmenke/267125e39598988c4df0 to your computer and use it in GitHub Desktop.
import UIKit
var myArray = [[1],[2,2],[3,3,3]]
func getElementCount(array array_I : [AnyObject]) -> Int {
var elementCount = 0
guard let nestedArray = array_I as? [[AnyObject]] else {
return array_I.count
}
for nest in nestedArray {
elementCount += getElementCount(array: nest)
}
return elementCount
}
getElementCount(array: myArray)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment