You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vari=1defadd(x: =>Int)(y: Int) = x + y
valf= add(i) _
f(1) // => 2
i +=1
f(1) // => 2!!!
I would expect the second f(1) to return 3, since the value of i has been incremented. It would seem that the partially-applied form of add (f) is memoizing its call-by-name parameter.
$$ scala -version
Scala code runner version 2.7.4.final--Copyright2002-2009, LAMP/EPFL
The text was updated successfully, but these errors were encountered:
Consider the following example:
I would expect the second f(1) to return 3, since the value of i has been incremented. It would seem that the partially-applied form of add (f) is memoizing its call-by-name parameter.
The text was updated successfully, but these errors were encountered: