Scala - Package

Card Puncher Data Processing

About

The content of a package can be scattered across many files.

Syntax

The following statement at the top of a file makes the code in a file part of the package foo.bar.

package foo.bar

Hierarchy

Package hierarchies should be reflected in directory structure.

A source file defining class myClass in package foo.bar should be stored in a subdirecotory as foo/bar/myClass.scala/

Scala does not really enforce this convention, but some tools such as the Scala IDE for eclipse might have problems otherwise.





Discover More
Card Puncher Data Processing
Scala - Import

In Scala, everything can be imported to make code available in your code (not only class names) _method package foo.bar will be available in your code. With the object baz in package foo.bar,...
Card Puncher Data Processing
Scala - Source File

Scala source code is stored in text files with the extension .scala. Typically Scala programmers create: one source file for each class, or one source file for a class hierarchy. In fact, Scala...



Share this page:
Follow us:
Task Runner