I have problems understanding correctly the use of class and their companion object.
When defining a case class there is its companion object that comes with it, but what is the result of defining an object having the same name as the case class? Does it override the companion object? And how to access case class parameters?
For example in TestCaseClass.scala file I define the following :
case class TestCaseClass(att1: String, att2: Int, att4s: List[String])
object TestCaseClass {
def iWantDoSomethingWithMyParams: String = {
att1 + " " + att2
}
// Other functions
}
object AnotherTestCaseClass {
def iWantDoSomethingWithTestCaseClassParams: String = {
// How to access TestCaseClass.att1
TestCaseClass.att1 + " " + TestCaseClass.att2
}
def iWantGetAllAttr4: List[String] = {
// ???
}
}