Skip to content

Instantly share code, notes, and snippets.

@macbellingrath
Last active July 9, 2016 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macbellingrath/1c06443ef0453a5676cdd7f18889f2f1 to your computer and use it in GitHub Desktop.
Save macbellingrath/1c06443ef0453a5676cdd7f18889f2f1 to your computer and use it in GitHub Desktop.
ClearHigherOrder.swift
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