Extending a Class
Extending a base class in Scala is similar to extending in Java except for two good restrictions: method overriding requires the override keyword, and only the primary constructor can pass parameters to a base constructor.
The Override annotation was introduced in Java 5 but its use is optional in Java. Scala insists that the keyword override is used when overriding a method. By requiring that keyword, Scala will help minimize errors that often arise from typos in method names. You can avoid either accidentally overriding a method unintentionally or writing a new method when your intent was to override a base method.
In Scala, auxiliary constructors have to call either the primary constructor or another auxiliary constructor. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access