None
NL
Scala Pitfall: Parameterless Function Calls and Misplaced vals
['Ben Congdon']
Ben Congdon
val isBarEnabled : Boolean = { cache.getValue( "bar" ) } } class BusinessLogic { val conf = new MyConfiguration () def handleRequest() { if (conf.isFooEnabled) { // Some code path } else { // Another code path } if (conf.isBarEnabled) { // Some code path } else { // Another code path } } } class ConfigurationFetcher [ T ](key : String , default : T ) { def getCurrentValue() : T = { ... } } class MyConfiguration { val fooEnabled : ConfigurationFetcher [ Boolean ] = ConfigurationFetcher ( "foo" , false ) } class BusinessLogic { val conf = new MyConfiguration () def handleRequest() { if (conf.fooEnabled.getCurrentValue()) { // Some code path } ...