Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let countryToRegionDic = [
- "United States" : "America",
- "Canada" : "America",
- "Czech Republic" : "Europe",
- "France" : "Europe",
- "Italy" : "Europe",
- ]
- let filters = ["Europe"]
- struct ShowData {
- var place: String
- var price: Int
- }
- var bound = [ShowData]()
- var newBound = [ShowData]()
- bound.append(ShowData(place: "United States", price: 100))
- bound.append(ShowData(place: "Canada", price: 200))
- bound.append(ShowData(place: "France", price: 300))
- bound.append(ShowData(place: "Italy", price: 400))
- bound.append(ShowData(place: "Czech Republic", price: 500))
- bound.forEach {
- let countryRegion = countryToRegionDic[$0.place]
- if let countryRegion = countryRegion, filters.contains(countryRegion) {
- let a = $0.place
- let b = $0.price
- let lol = ShowData(place: a, price: b)
- newBound.append(lol)
- }
- }
- print(newBound)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement