From the course: Introduction to Scala
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Challenge: Lists - Scala Tutorial
From the course: Introduction to Scala
Challenge: Lists
(upbeat music) - [Instructor] Let's do our list challenge. So in the REPL, let's create a new list and create an empty list. Also in the REPL, let's write this list out, then let's get the head and the tail of this list, find all the unique values, get the first three elements, find the length of the list, map over the list multiplying each number by itself, and then FlatMap over the list to create three duplicates for each element. Now moving into the IDE, let's create a case class called Destination which has two fields, a city, which is of type String and a journeyTime of type Int, write a list of destinations of your choice, and then we've decided that we want to take a short getaway, so use a for comprehension to iterate through your list of destinations and filter for ones that have a shorter journeyTime of your choosing.
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.