Hi! I am running into the following issue:
The goal of my code is to check a string "text" to see if it contains any variables from a list of allergens (from a different view). If one of the allergens appear in the string, then I want it to appear in the output list. So the user may list a total of 5 allergens, and if only 3 of the allergens are in the "text" string, then those 3 will appear in the output list.
However, I run into the following error: Unable to infer complex closure return type; add explicit type to disambiguate
I understand a lot of other users have had that issue, but I am still unable to figure out how to fix it for my current issue.
I am very new to programming in general, so any help is really appreciated!
var body: some View {
NavigationView {
List {
ForEach(allergens.items) {_ in // The error occurs here!
if allergens.contains(where: self.text.contains){
Text(allergens.items)
}
}
}
}}