scala - Why can't I access my objects member variable? -



scala - Why can't I access my objects member variable? -

i have next class setup:

class myclass { class myinnerclass(membervar: string) def getainner: myinnerclass = { new myinnerclass("hello") } }

then have next code outside of class:

def myfunction = { val = new myclass val b = a.getainner.membervar // value membervar not fellow member of a.myinnerclass }

why this?

you need add together keyword val create membervar public otherwise it's private value:

class myclass { class myinnerclass(val membervar: string) def getainner: myinnerclass = { new myinnerclass("hello") } }

scala

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -