[scala-functional] lazy val memoization

2018-04-10 Thread des . magner
Hi Based on my understanding of the explanation of lazy val memoization in section 5.2.1, I would have thought that if I define the following function: def func(i: => Int): Unit = { lazy val cached = { println("Calculating") i * i } cached

[scala-functional] Re: lazy val memoization

2018-04-10 Thread des . magner
Ah OK. So I am guessing I misunderstood section 5.2.1. The "cons" function is only ever called once in this scenario? On Tuesday, 10 April 2018 17:19:24 UTC+2, des.m...@gmail.com wrote: > > Hi > > Based on my understanding of the explanation of lazy val memoization in > section 5.2.1, I would