class Wesley: Developer {
let name = "Wesley de Groot"
let age = 34
let location: Location = .Netherlands
let languages: [Languages] = [.Dutch, .English]
let programmingLanguages = ["Swift", "Objective-C", "JavaScript", "PHP"]
let markup = ["HTML", "CSS"]
func details() -> String {
var details = ""
for detail in Mirror(reflecting: self).children {
guard let label = detail.label else { continue }
details.append("\(label.capitalized): \(detail.value)\n")
}
return details
}
}
print(Wesley().details())
// The above doesn't compile?
// Just add this "missing" code.class Developer {
enum Location { case Netherlands }
enum Languages { case Dutch, English }
}
Exploring the .inspector Modifier in SwiftUI
My projects have 194 ⭐️, and 33 Forks.
Interested learning more about Swift? Check out my blog.