O'Reilly logo

Programming Scala by Alex Payne, Dean Wampler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reserved Words

Table 2-4 lists the reserved words in Scala, which we sometimes call “keywords,” and briefly describes how they are used (see [ScalaSpec2009]).

Table 2-4. Reserved words

WordDescriptionSee …

abstract

Makes a declaration abstract. Unlike Java, the keyword is usually not required for abstract members.

Class and Object Basics

case

Start a case clause in a match expression.

Pattern Matching

catch

Start a clause for catching thrown exceptions.

Using try, catch, and finally Clauses

class

Start a class declaration.

Class and Object Basics

def

Start a method declaration.

Method Declarations

do

Start a do...while loop.

Other Looping Constructs

else

Start an else clause for an if clause.

Scala if Statements

extends

Indicates that the class or trait that follows is the parent type of the class or trait being declared.

Parent Classes

false

Boolean false.

The Scala Type Hierarchy

final

Applied to a class or trait to prohibit deriving child types from it. Applied to a member to prohibit overriding it in a derived class or trait.

Attempting to Override final Declarations

finally

Start a clause that is executed after the corresponding try clause, whether or not an exception is thrown by the try clause.

Using try, catch, and finally Clauses

for

Start a for comprehension (loop).

Scala for Comprehensions

forSome

Used in existential type declarations to constrain the allowed concrete types that can be used.

Existential Types

if

Start an if clause.

Scala if Statements

implicit

Marks a method as eligible to be used as an implicit ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required