Scala - Import
Table of Contents
About
In Scala, everything can be imported to make code available in your code (not only class names)
Articles Related
Management
Package
package foo.bar will be available in your code.
import foo.bar._
Object
With the object baz in package foo.bar, the following would import all the members of that object.
import foo.bar.baz._
The import statement imports all members of the foo.bar.baz class. This makes visible:
- the static method
- and the static fields
Class
If you define a class MyClass in package foo.bar, you can import that specific class (and not anything else from that package) with
import foo.bar.MyClass.
Multiple classes can be imported from the same package by enclosing them in curly braces:
import java.util.{Date, Locale}