Scala - initialization order of vals
问题 I have this piece of code that loads Properties from a file: class Config { val properties: Properties = { val p = new Properties() p.load(Thread.currentThread().getContextClassLoader.getResourceAsStream("props")) p } val forumId = properties.get("forum_id") } This seems to be working fine. I have tried moving the initialization of properties into another val, loadedProperties , like this: class Config { val properties: Properties = loadedProps val forumId = properties.get("forum_id") private