It will fail to compile, because "i cannot be found".
This is so, because the right-hand side of the assignment is supposed to be an ordinary Scala code that doesn't belong to any node, and, hence, doesn't have a here variable in scope. Hence, i can't be evaluated.
A workaround goes as follows:
def script live = (
val i = 4
val j: Int = 0
{j = i}
)
A good way to solve the problem would be to include the implicit here variable to the right-hand side block of the assignment. The here variable can evaluate to the n-ary operator the assignment belongs to - the sequential operator in the latter example.
Consider the following script:
It will fail to compile, because "i cannot be found". This is so, because the right-hand side of the assignment is supposed to be an ordinary Scala code that doesn't belong to any node, and, hence, doesn't have a
here
variable in scope. Hence,i
can't be evaluated.A workaround goes as follows:
A good way to solve the problem would be to include the implicit
here
variable to the right-hand side block of the assignment. Thehere
variable can evaluate to the n-ary operator the assignment belongs to - the sequential operator in the latter example.