Changing Scala lazy val behaviour -


suppose have string type lazy val :

     class lazyvals {        lazy val message = "i lazy on + " + system.currenttimemillis().tostring           def changelazy = { message + " not!!" }     } 

will changelazy change "evaluate once only" nature of message?

code calculate message evaluated once only. can't change behavior.

currenttimemillis called once. concatenation message + " not!!" performed on each changelazy call same result, can optimized jvm.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -