A val declaration binds a name immutably to a value. In formatAbs, val msg gives the formatted string a name before msg.format uses it, separating local data from the surrounding computation. section 2.1
Naming an intermediate value
private def formatAbs(x: Int) = val msg = "The absolute value of %d is %d." msg.format(x, abs(x)) The declaration evaluates the string expression, binds its result to msg, and makes that value available to the following expression. section 2.1
