I know that in Scala you can alias things inside package like that: import some.package.{someObject => someAlias}
Is there a way of creating alias for package name, not for classes/objects inside it ?
For example in Python you can do:
import package as alias
You can alias a package name the same way you alias an object.
import scala.collection.{mutable => m}
val buffer = m.ListBuffer(1, 2, 3, 4)
buffer: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3, 4)
Fun fact: You can also alias object methods this way.
import scala.collection.mutable.ListBuffer.{apply => makeBuffer}
scala> makeBuffer(1, 2, 3, 4)
res5: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3, 4)
import org.joda.time.{DateTime => joda}
Now you can use joda as synonym for DateTime
joda.parse("2014-12-23")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With