I saw some scala code that assign "_" to a field of class, what does it mean ? Thanks
private var tk: TaggedKey = _
I saw some scala code that assign "_" to a field of class, what does it mean ? Thanks
private var tk: TaggedKey = _
It means: assign default value. Default value is defined as null, 0 or false depending on the target type.
It is described in 4.2 Variable Declarations and Definitions of the The Scala Language Specification:
A variable definition
var x : T = _can appear only as a member of a template. It introduces a mutable field with type T and a default initial value. The default value depends on the type T as follows:
0- ifTis Int or one of its subrange types,
0L- ifTis Long,
0.0f- ifTis Float,
0.0d- ifTis Double,
false- ifTis Boolean,
()- ifTis Unit,
null- for all other typesT.