I have the following code:
struct Quiz {
var gender = "she"
var quizQuestions = ["Is \(gender) nice?", "Is \(gender) great?", "Is \(gender) wonderful?"]
}
But I get the following error message:
Cannot use instance member 'gender' within property initializer; property initializers run before 'self' is available
Is there any way to alter this variable within the struct? I'm a novice with Swift - I'm trying to make a quiz app where the questions are contained in a struct. The first step for a user is to choose 'male/female', and so from then on the quiz questions should reflect that choice. I could create another struct with the same questions with the opposite gender pronouns, but this seems like a waste of space. I want one 'quizQuestions' array that will reflect the correct gender choice from an independent UIbutton. So any advice in general on how to approach this would be great. TIA.