inheritance - Scala: how to inherit a "static slot"? -


Well, I'm learning Scala so this question is very basic for most people.

In Java, a class can have a fixed slot (function or variable), and then I will have that slot even in the heritage classes.

I do not have fixed slots in Scala, but I have fellow objects. But I am aware that these objects are not part of the heritage classroom, so if I have two classes person and student , and the person has a variable All: List which gives a list of all people, so I can do Person.all , I was hoping that I can also do Student.all

Thank you!

thanks

In principle, speaking in this context The behavior of too many is broken due to the fact that sub-classes raise static members do not really make sense with the view of an object-oriented point. Figures are really nothing more than fancy, scrap globals. Inheritance is something that you see at the class level, but the situation is not actually at the classroom level (because they are global) Therefore the heritage should not be applied. The fact is that this happens in Java ... bothered.

Scala has actually taken a high road in this department; For which we should be grateful to all, as in another answer, the right way to define the "inherited" situation is to remove the members of the heritage in a special property:

 

This is unnecessarily high Verbose is compared to Java, but I believe when I say that semantics are less surprising as a result.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -