This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a short recipe, Recipe 4.9, “How to set uninitialize var field types in Scala.”
You want to set the type for an uninitialized
var field in a Scala class, so you begin to write code like this:
var x =
and then wonder how to finish writing the expression.