I'm a newbie in Scala, and I have a Scala program with a class and a companion object, and I want to use a type alias that is used :
The concrete code is available at https://github.com/juanrh/Surus/blob/1cfd55ed49c4d1b22e53babe07bcf44fd74e3072/src/main/scala/org/surus/spark/SurusRDDFunctions.scala, the type alias is PMMLPrediction and the class is SurusRDDFunctions. Currently the code works but I have defined the alias both in the class and the companion, which is not very nice. If I remove the definition of the alias in the class then the class is not able to find it, which seems weird. So I think I'm probably doing something wrong, any ideas?
Thanks a lot in advance for your help!
Greetings,
Juan
Given the companion object
object Example {
type MyString = String
}
You can access the type directly through to the companion object
class Example (val name: Example.MyString) { }
Or by importing it from the companion object
class Example {
import Example._
val name: MyString = "example"
}