O'Reilly logo

Pragmatic Scala by Venkat Subramaniam

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

Sensible Defaults

Scala has some defaults that make code concise and easier to read and write. Here are a few of these features:

  • It has support for scripts. Not all code needs to be within a class. If a script is sufficient for your needs, put the executable code directly in a file without the clutter of an unnecessary class.

  • return is optional. The last expression evaluated is automatically returned from method calls, assuming it matches with the return type declared for the method. Not having to put in that explicit return makes code concise, especially when passing closures as method parameters.

  • Semicolons (;) are optional. You don’t have to end each statement or expression with a semicolon—see Semicolon Is Semi-optional—and this reduces ...

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