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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access