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
Post a Comment