A block expression groups multiple Scala statements into one expression. Statements can be separated by newlines or semicolons, and curly braces are often optional. The block’s value is the value produced by its final expression. section 2.1
Naming an intermediate value
In `formatAbs`, `val msg = "The absolute value of %d is %d"` binds an immutable intermediate value. The final expression, `msg.format(x, abs(x))`, becomes the block’s value and therefore the method’s result. The block keeps preparation and final computation together without an explicit `return`. section 2.1
private def formatAbs(x: Int) = val msg = "The absolute value of %d is %d." msg.format(x, abs(x)) #1
Inspect the compact Scala definition showing an intermediate `val` followed by the expression that determines the block result. section 2.1
