Primitives in Scala
Explore how Scala treats all data types as objects, with primitives compiled for performance. Learn about first-class functions, concise class definitions, and how everything in Scala is an expression with return values, eliminating the need for a return keyword.
We'll cover the following...
We'll cover the following...
Everything’s an object
Scala has no primitives in Java. In other words, when coding in Scala, everything is an object. However, the compiler will compile your code down to primitive math (if possible), so you don’t lose performance. In addition, functions are considered first-class citizens in Scala, which means they can be passed around as values. These factors are why people say that Scala combines the features of object-oriented and functional languages.
To achieve this feat, ...