class - Defining classes: difference between var, val and leaving it out? -
this question has answer here:
what difference between following 3 scala declarations? understand general distinction between val , var.
class a(x: t){ ... } class b(val x: t){ ... } class c(var x: t){ ... }
difference between a
, b
(both val
, var
create accessor):
class a(a: int) {} // doesn't compile (value not member of) // (new a(1)).a class b(val b: int) {} (new b(1)).b //> res0: int = 1
Comments
Post a Comment