What would be the difference between the following three Scala declarations? I understand the general distinction between val and var.
class A(x: T){ ... }
class B(val x: T){ ... }
class C(var x: T){ ... }
What would be the difference between the following three Scala declarations? I understand the general distinction between val and var.
class A(x: T){ ... }
class B(val x: T){ ... }
class C(var x: T){ ... }
Difference between A
and B
(both val
and var
create accessor):
class A(a: Int) {}
// Doesn't compile (value a is not a member of)
// (new A(1)).a
class B(val b: Int) {}
(new B(1)).b //> res0: Int = 1