Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protocol AnyArray{}/*<--Neat trick to assert if a value is an Array, use-full in reflection and when the value is Any but really an array*/
- extension Array:AnyArray{}//Maybe rename to ArrayType
- func recFlatMap<T>(_ arr:[AnyObject]) -> [T]{
- var result:[T] = []
- Swift.print("arr.count: " + "\(arr.count)")
- arr.forEach{
- if($0 is AnyArray){
- let a:[AnyObject] = $0 as! [AnyObject]
- result += recFlatMap(a)
- }else{
- result.append($0 as! T)
- }
- }
- return result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement