From the course: Scala Essential Training for Data Science

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Scala sets Scala arrays, vectors, and ranges

Scala sets Scala arrays, vectors, and ranges - Scala Tutorial

From the course: Scala Essential Training for Data Science

Scala sets Scala arrays, vectors, and ranges

- [Instructor] Let's talk about Scala arrays, vectors and ranges. First, we'll start with scala REPL. Scala arrays are indexed collections of values much like you'll find in other programming languages. Arrays are a mutable collection type. Let's create an array of temperatures. So, we'll use val temps and we'll create an array and we'll forget about units of measure now and just simply work with integers, 50, 51, 56, 53 and 40. Arrays in Scala are zero based, so getting the array value at index one returns actually the second item in the array, so for example, if we say temps of one we'll get 51. If we want the first item, we should use zero. Scala is an object-oriented language. Variables, including arrays, are objects and have methods associated with them. To find the length of an array, we can use the length method which is invoked by specifying a value name followed by a period and the word length as in temps.length returns five which is the length of the array. The values in…

Contents