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
import Foundation | |
// nestedArrays will be a sample case to test our function | |
var nestedArrays = [[1,2,[3,[4,5]]],6] as [Any] | |
func flattenArray(nestedArrays array: [Any]) -> [Int]{ | |
var newArray = [Int]() | |
array.forEach { item in | |
// recursively check is array item is an array, if so, pass it to flattenArray func | |
if let arrayItem = item as? [Any] { |