newbie to swift, a contrived example. I have an array of menu categories, which in turn have menu items I want to loop through the categories and then read the elements of the sub-array of items. Don't know the syntax to reference the element as an array
ERROR at line 10, col 18: type 'String' does not conform to protocol 'Sequence' for (item) in offering {
var menuOffering = ["drinks" , "breakfastEntree"]
var drinks: Set = ["water","milk","coffee","tea","diet coke"]
var breakfastEntree: Set = ["eggs", "bacon", "sausage","pancakes"]
for ( offering) in menuOffering {
print ("\(offering)")
for (item) in offering { ERROR
print ("\(item)")
}
}
: Setand let type inference do the work for you. Sets are unordered (so these could print out in any order), and are generally used when the collection could be very large and a common operation is "test wether X is a member of the set." For day-to-day use, you generally want Arrays (which is why you get them for free if you don't ask for: Set). To your actual question, see triple.s below.