I am exploring scala with a background from java. I am trying to understand usage of _ when it has been used to set the value of an attribute.
This is my code snippet.
class RectAngle{
var length=1
var height=20
}
object RectAngleDemo extends App{
var f = new RectAngle()
f.length=20;
f.length_=(10)
println(f.length);
f.height=20;
}
From the code, I know that value of length is 10 but don't know how it is allowed and how it worked here.
I have gone through other question (for which this question has been marked as duplicate) and still did not understand the concept with respect to my current query.
I am interested only in this example because digesting other question is very difficult at this juncture due to lot of theory in it without examples.
In above example, how does _ work?