Why doesn't Scala have static members inside a class?

前端 未结 5 1449
忘掉有多难
忘掉有多难 2020-12-12 22:05

I know you can define them indirectly achieve something similar with companion objects but I am wondering why as a language design were statics dropped o

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-12 22:30

    Object oriented programming is all about objects and its states(Not touching state full and stateless objects in Java). I’m trying to stress “Static does not belong to objects”. Static fields cannot be used to represent a state of an object so it’s rational to pull off from objects.

提交回复
热议问题