Last active
March 2, 2016 11:17
-
-
Save gigiigig/d9df15de3a7d509f3c9e to your computer and use it in GitHub Desktop.
Simple config example
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
trait Config { | |
val timeout: Int = 1 | |
val interval: Int = 2 | |
def wantToChangeThis: Int | |
} | |
object DefaultConfig extends Config { | |
val wantToChangeThis: Int = 34 | |
} | |
class Foo(conf: Config) { | |
def run = { | |
println(conf.timeout) | |
println(conf.interval) | |
} | |
} | |
// This will be the defualt to use, but external caller can still override | |
// configs easily | |
object Foo extends Foo(DefaultConfig) | |
Foo.run | |
// 1 | |
// 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment