Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// is there a way to make this an awesome for comprehension or whatever?
// or maybe a built in Map method to do what I want? ;p
val codes: List[String] = ...
val configs: Map[String, Configuration] = ...
val defaultConfig: Configuration = ...
val config: Configuration = codes
.find(configs.contains) // find the first code that the configs map contains
.flatMap(configs.get) // grab the config for that first code
.getOrElse(defaultConfig) // if no config, get the default config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment