I am creating a Quiz and I have an array of bools and I am trying to find a way to count how many "true" & "false" values there are, so I can present the results of the quiz to the user. I would like to store the results in a variable I can call at a later point.
I have looked at the set collection type but can`t seem to wrap my head around it. Do I initalise set to a bool?
answersArray = [true, false, true, false, true, false, true]
trueAnswersCount = set<Bool>()
You can easily use the functional programming power of Swift to obtain a very concise solution for your problem: