Enter aliases only an alias of the type, and not any companion object that can supply factory methods (regardless of whether you write this factory method yourself or get it "free" from the compiler).
On the other hand, when importing actions with names, and if there are several objects associated with a given name, the import of this name brings into each referent of the imported name. In addition, you can rename upon import, and you can do this multiply, so ...
scala> object Stuff { case class Thing(id: String, name: String) } defined module Stuff scala> import Stuff.Thing import Stuff.Thing scala> import Stuff.{Thing => Foo} import Stuff.{Thing=>Foo} scala> import Stuff.{Thing => Bar} import Stuff.{Thing=>Bar} scala> val thing1 = Thing("fing", "fang") thing1: Stuff.Thing = Thing(fing,fang) scala> val foo1 = Foo("yes", "no") foo1: Stuff.Thing = Thing(yes,no) scala> val bar1 = Bar("true", "false") bar1: Stuff.Thing = Thing(true,false)
This is not useful for rendering via toString , though, as you can see.
Randall schulz
source share