From the course: Scala Essential Training for Data Science

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Scala objects

Scala objects - Scala Tutorial

From the course: Scala Essential Training for Data Science

Start my 1-month free trial

Scala objects

- [Instructor] Now we're going to discuss Scala classes and objects. I'm going to start the Scala REPL. Classes are definitions of structures and operations on those structures. Recall that Scala is an object oriented language and variables are all objects. When we create a variable or value of a particular data type we can access the operations that are defined on that type. For example, when we create an array we get access to a method, which can sort the elements of the array. Let's create a value, we'll call it y, and we'll say that it's an Array. And let's give it some names of countries, like England, Liberia, Haiti, Australia, and Sweden. Now the Array, of course, will order the elements according to how we entered them, but I can say y and call the sorted method on the Array y and it will return a sorted version, in this case alphabetical order version, because it's strings. Now we get this because the sort method is defined for Arrays. Now often when working with data sets it…

Contents