It's reasonable to follow common object-oriented programming practices and have getters and setters in the public interface, but within a class you should always access fields directly.
通常根据面向对象语言的实践,在公共接口中使用Getters和Setters是有道理的,但在一个字段经常被访问的类中宜采用直接访问。
The class and object can have the same name, as we will see in the section called "Companion Objects" in Chapter 6, Advanced Object-Oriented Programming in Scala.
类和object可以使用同样的名字,就像我们会在《第6章-Scala高级面向对象编程》的“伴随实体”章节中看到的那样。
We'll explore this class in greater detail in Chapter 5, Basic Object-Oriented Programming in Scala.
我们会在《第5章-Scala基础面向对象编程》中来探索这个类的更多细节。
In object-oriented programming, an object is the product or instance generated by a class.
在面向对象编程中,对象是产物或被类产生的实例。
In object-oriented programming, an object is the product or instance generated by a class.
在面向对象编程中,对象是产物或被类产生的实例。
应用推荐