Advertisement
Adnako

What I'm doing wrong?

Feb 15th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.90 KB | None | 0 0
  1. let countryToRegionDic = [
  2.     "United States" : "America",
  3.     "Canada" : "America",
  4.     "Czech Republic" : "Europe",
  5.     "France" : "Europe",
  6.     "Italy" : "Europe",
  7. ]
  8.  
  9. let filters = ["Europe"]
  10.  
  11. struct ShowData {
  12.     var place: String
  13.     var price: Int
  14. }
  15.  
  16. var bound = [ShowData]()
  17. var newBound = [ShowData]()
  18.  
  19. bound.append(ShowData(place: "United States", price: 100))
  20. bound.append(ShowData(place: "Canada", price: 200))
  21. bound.append(ShowData(place: "France", price: 300))
  22. bound.append(ShowData(place: "Italy", price: 400))
  23. bound.append(ShowData(place: "Czech Republic", price: 500))
  24.  
  25. bound.forEach {
  26.     let countryRegion = countryToRegionDic[$0.place]
  27.  
  28.     if let countryRegion = countryRegion, filters.contains(countryRegion) {
  29.         let a = $0.place
  30.         let b = $0.price
  31.  
  32.         let lol = ShowData(place: a, price: b)
  33.         newBound.append(lol)
  34.     }
  35. }
  36.  
  37. print(newBound)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement