Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下三个 Scala 声明之间有什么区别?我了解val 和 var 之间的一般区别。
class A(x: T){ ... } class B(val x: T){ ... } class C(var x: T){ ... }
A和B(val和var创建访问器)之间的区别:
A
B
val
var
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