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
Here is the block of code to reproduce the problem:
objectTestItextendsApp {
{ // if you remove this bracket block, the compiler does not complaindefmemoize1[A, B](f: A=>B):Function1[A, B] =newFunction1[A, B] {
valresults= collection.mutable.Map.empty[A, B]
defapply(in: A) = results.getOrElseUpdate(in, f(in))
}
valmaxLatency1:Function1[(Int, Int), Int] = memoize1 { t: (Int, Int) =>val (s, d) = t
if (s == d) 0else {
maxLatency1((1, 2))
}
}
} // end of block
}
The text was updated successfully, but these errors were encountered:
You can make maxLatency a lazy val to make this allowed.
The scope of a name introduced by a declaration or definition is the whole statement
sequence containing the binding. However, there is a restriction on forward references in blocks:
In a statement sequence s1 . . . sn making up a block, if a simple name in si refers to an entity
defined by s j where j >= i , then for all sk between and including si and sj,
* sk cannot be a variable definition.
* If sk is a value definition, it must be lazy.
Here is the block of code to reproduce the problem:
The text was updated successfully, but these errors were encountered: