Last active
August 29, 2015 14:10
-
-
Save eyston/268add01dc4287553820 to your computer and use it in GitHub Desktop.
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
// 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