I want to better understand recursive looping and flatten in Swift or any other language for that matter.
I have a simple Swift class
class Survey {
let items: [SurveyItem]?
}
class SurveyItem {
let id: String?
let items: [SurveyItem]?
}
A Survey has items and each item can have more types of its own.
I want to write a function which assembles all items and subitems in a survey into a single flat array