Hi guys
I have a question which I always stumble upon. Say you have two structures as follows:
Should the function be coded in Person or within Occupation? Of course it would be named something like isOfKind(_ occupation: String)
Tx!
I have a question which I always stumble upon. Say you have two structures as follows:
Code:
struct Occupation {
let name: String
}
struct Person {
let firstName: String
let lastName: String
var occupations: [Occupation]
func hasAnOccupationOfKind(occupation occupationToMatch: String) -> Bool{
var match = false
for occupation in occupations {
if occupation.name == occupationToMatch { match = true}
}
return match
}
}
Tx!