Naming case classes in Scala?

Since class, trait and object names are package scoped, why not use the package to provide insurance against aliasing with other nodes and leafs and call them simply Node and Leaf while leaving them outside any other scoping construct (i.e. , an object)?

Since class, trait and object names are package scoped, why not use the package to provide insurance against aliasing with other nodes and leafs and call them simply Node and Leaf, while leaving them outside any other scoping construct (i.e. , an object)?

– ŝukasz Lew May 9 '10 at 0:25 1 Package objects are scopes that can hold any kind of Scala entity, particularly those that cannot really appear at the top level / globally due to JVM restrictions. You can put def, val (or var) and type declarations in package objects but only traits, classes and objects at the top level. Companions are class / object pairs (that share a name) and which are defined in the same source file.

Companions can access each other's private members. – Randall Schulz May 9 '10 at 3:28.

I wouldn't recommend putting the case classes inside their abstract superclass because nested classes are path dependent in Scala. If anything, you could put them inside a companion object. Abstract class MyTree object MyTree { case class Node (...) extends MyTree case class Leaf (...) extends MyTree } (note: I haven't tested this...).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions