In Scala, a class's primary constructor has no explicit body, but is defined implicitly from the class body. How, then, does one distinguish between fields and local values (i.e. values local to the constructor method)?
For example, take the following code snippet, a modified form of some sample code from "Programming in Scala":
class R(n: Int, d: Int) {
private val g = myfunc
val x = n / g
val y = d / g
}
My understanding is that this will generate a class with three fields: a private "g", and public "x" and "y". However, the g value is used only for calculation of the x and y fields, and has no meaning beyond the constructor scope.
So in this (admittedly artificial) example, how do you go about defining local values for this constructor?