Scala parameters for access modifiers?

前端 未结 2 1868
北荒
北荒 2021-01-19 10:58

What is the difference between

class Test {
  private[this] val foo = 0
}

vs

class Test {
  private val foo = 0
}
         


        
2条回答
  •  独厮守ぢ
    2021-01-19 11:29

    The first one is private for instance class, second is for class. If you use second version you have access from another instance of Test class (it's usefull for equals method or similiar).

提交回复
热议问题