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 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
The advantages of Scala for data science1m 34s
-
(Locked)
Installing Scala2m 56s
-
(Locked)
Scala data types4m 34s
-
(Locked)
Scala collections1m 17s
-
(Locked)
Scala sets Scala arrays, vectors, and ranges5m 37s
-
(Locked)
Scala maps4m 28s
-
(Locked)
Scala expressions3m 40s
-
(Locked)
Scala functions2m 46s
-
(Locked)
Scala objects8m 5s
-
-
-
-
-
-