Import clauses

Import clauses
An import clause has the form import p.X where the import expression X determines a set of names of members of p which are made available without qualification.
import p._	// all members of p (this is analogous to import p.* in Java).
import p.x	// the member x of p.
import p.{x => a}	// the member x of p renamed as a.
import p.{x, y}	// the members x and y of p.
import p1.p2.z	// the member z of p2, itself member of p1.
 
Furthermore, the clause import p1._, p2._ is a shorthand for import p1._; import p2._. Implicitly imported into every compilation unit are, in that order:
  • the package java.lang,
  • the package scala,
  • and the object scala.Predef.
Members of a later import in that order hide members of an earlier import.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Scala snippets
Cosmo
Sign Up Now
or Subscribe for future quizzes