scala - How to create private fields that my functions will return -


my class looks like:

class webconfig(config: config) {    def this() {      this(configfactor.load())   }    def dbport = config.getint("mysql.port")  } 

i don't when call dbport, has call , cast config each , every time.

so want create private fields , set them in constructor, calling dbport return private field has.

how can this?

i tried creating private var getting error:

 class webconfig(config: config) {       private var _dbport: int       def this() {          this(configfactor.load())           _dbport = config.getint("mysql.port")       }        def dbport: int = _dbport      } 

error:

abstract member may not have private modifier 

can't write this:

class webconfig(config: config) {    def this() {      this(configfactor.load())   }    val dbport = config.getint("mysql.port")  } 

it read config parameter 1 time.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -