Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Empty arrays are not in the challenge. That said, it was an interesting challenge to address.
The reason some are removed is the flattening logic removes and second level and beyond empty arrays.
To remove the first level empty arrays, add a filter to the return value:
.filter { !(($0 as? Array<Any>)?.isEmpty ?? false) }
Why
.compactMap{ $0.wholeNumberValue}
?Your if statement is acting as a guard clause. Would read better if you used guard since those are expected to bail.
if ... return is really acting as a guard clause. it would be better to use a guard.