I got the key from the dictionary using reduce like by doing the following:
let namesAndScores = ["Anna": 2, "Brian": 2, "Craig": 8, "Donna": 6]
let namesString = namesAndScores.reduce("",
combine: { $0 + "\($1.0), " })
print(namesString)
But I would like to know how to get the value from the dictionary using the reduce ?.
Any help would be appreciated. Thanks.
combine: { $0 + "\($1.0), " }), you use$1.0to get thekeyfrom thedictionary, you also can use$1.1to get thevalue. Is this you want?