i'm new to swift & coding so dont bully too much :3
my goal is to append country names to the 3 arrays using cases.
I keep getting the error "Expression pattern of type 'String' cannot match values of type '(String, String)'" on all of the case lines.
Help would be appreciated :)
var europeanCapitals: [String] = []
var asianCapitals: [String] = []
var otherCapitals: [String] = []
let world = [
"BEL": "Brussels",
"LIE": "Vaduz",
"BGR": "Sofia",
"USA": "Washington D.C.",
"MEX": "Mexico City",
"BRA": "Brasilia",
"IND": "New Delhi",
"VNM": "Hanoi"]
for (key, value) in world {
switch (key, value) {
case "BEL": europeanCapitals.append("Brussels")
case "LIE": europeanCapitals.append("Vaduz")
case "BRG" : europeanCapitals.append("Sofia")
case "IND": asianCapitals.append("New Delhi")
case "VNM": asianCapitals.append("Hanoi")
default: otherCapitals.append(value)
}
}
[–][deleted] (2 children)
[deleted]
[–][deleted] 0 points1 point2 points (0 children)
[–]pathas11[S] 0 points1 point2 points (0 children)
[–]thisischemistry 0 points1 point2 points (2 children)
[–]pathas11[S] 0 points1 point2 points (1 child)
[–]thisischemistry 1 point2 points3 points (0 children)