Last active
July 9, 2016 16:55
-
-
Save macbellingrath/1c06443ef0453a5676cdd7f18889f2f1 to your computer and use it in GitHub Desktop.
ClearHigherOrder.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pushTopicSubscriptionStates = ["Sports": true, "News": false] | |
// an array of topics that user is subscribed to | |
let subscribedUserTopics = pushTopicSubscriptionStates.filter { (_, subscribed) in subscribed } | |
.map { (topic, _) in topic | |
} | |
let topicsDictionary = ["Sports": ["a", "b","c"], "Weather": ["a", "b","c"]] | |
let subscribedBackendTopics = topicsDictionary.filter { (key, _) in subscribedUserTopics.contains(key) } | |
.flatMap { (_, value) in value } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment