Table A-1 displays the reserved words in Scala. Reserved words are part of the Scala language definition, and cannot be used as identifiers. To keep the definitions concise, I have used “class” where “class, object, and trait” may be more accurate.
The wildcard operator, representing an expected value.
Delimits a value, variable, or function from its type.
Defines an annotation for a class or its member. Annotations are a JVM feature but are seldomly used in Scala, with
A type projection, which delimits a type from its subtype.
Delimits a generator from its identifier in a for-loop.
A single-character (\u2190) alternative to
The upper-bound operator, restricting types to those that are equal to or extend the given type.
The view-bound operator, allowing any type that may be treated as the given type.
The assignment operator.
Used in match expressions and partial functions to indicate a conditional expression, in function types to indicate a return type, and in function literals to define the function body.
A single-character (\u21D2) alternative to
The lower-bound operator, restricting types to those that are equal to or are extended by the given type.
Marks a class or trait as being abstract and uninstantiable.
Defines a matching pattern in match expressions and partial functions.
Catches an exception. An alternate syntax that predates the
Defines a new class.
Defines a new method.
Part of the
The second part of an
Defines a base type for a class.
One of the two
Marks a class or trait as being nonextendable.
Executes an expression following a
Begins a for-loop.
Defines an existential type. Existential types are a flexible method for specifying type requirements, but are discouraged in general Scala development. See SIP-18 (Scala Improvement Process #18) for details on why existential types are considered an “opt-in” feature in Scala.
The first part of an
Defines an implicit conversion or parameter.
Imports a package, class, or members of a class to the current namespace.
Defines a value as being lazy, only defined the first time it is accessed.
Begins a match expression.
Creates a new instance of a class.
A value that indicates the lack of an instance. Has the type
Defines a new object.
Marks a value or method as replacing the member of the same name in a base type.
Defines the current package, an incremental package name, or a package object.
Marks a class member as being inaccessible outside the class definition.
Marks a class member as being inaccessible outside the class definition or its subclasses.
Explicitly states the return value for a method. By default, the last expression in a method is used as the return value.
Marks a class as only allowing subclasses within the current file.
Marks a class member reference as one in the base type, versus one overridden in the current class.
Marks a class member reference as one in the current class, versus a parameter with the same name.
Raises an error condition that breaks the current flow of operation and only resumes if the error is caught elsewhere.
Defines a new trait.
One of the two
Marks a range of code for catching an exception. An alternate syntax that predates the
Defines a new type alias.
Defines a new, immutable value.
Defines a new, mutable variable.
Part of the
Defines a base trait for a class.
Yields the return value from a for-loop.