curly braces

How to import multiple members in Scala (wildcard and curly braces syntax)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is one the shorter recipes, Recipe 7.2, “How to import multiple members in Scala (wildcard and curly braces syntax).”

Problem

You want to import one or more members into the scope of your current program.

Solution

This is the syntax for importing one class:

import java.io.File

You can import multiple classes the Java way:

How to package Scala code with the “curly braces” style

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 7.1, “How to package Scala code with the 'curly braces' style.”

Problem

You want to use a nested style package notation, similar to the namespace notation in C++ and C#.

Solution

Wrap one or more classes in a set of curly braces with a package name, as shown in this example: