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

Fundamental Types

Even though you can use any Java type in Scala, you can also enjoy a few types native to Scala. Scala makes a clearer distinction between value types and reference types and also goes a few extra miles with type definitions to enhance type verification and inference. Let’s get a grasp of these fundamental types since you’ll encounter these types in Scala quite often.

The Any Type

Scala’s Any type is a superclass of all types, as you can see here.

images/UsingTypeInference/scalatypes.png

Any can serve as a common reference to objects of any type. Any is an abstract class with the following methods: !=, ==, asInstanceOf, equals, hashCode, isInstanceOf, and toString.

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