I'm trying to extract values out of an array and concatenate all the values in one string like the following
var ingredient: String
for tag in tags {
if let text = tag.titleLabel?.text {
ingredient += " \(text)"
}
}
recipe.ingredients = ingredient
But I Xcode complains:
Variable "ingredient" passed by reference before being initialized
I think it complains that ingredient is initialized but has no value to start with for concatenation. Is that right? How can I achieve what I want?