A List is part of the Scala Collections library and it represents a list of data elements. Lists are processed in the same way as an array, but unlike arrays, elements of a list cannot be changed by assignment.
- [Voiceover] In the Scala collections library,…in addition to arrays, sets, and maps,…we also have a type called list.…Lists are processed in the same way as an array,…but unlike an array, elements of a list…cannot be changed using an assignment.…Let's create a worksheet in our worksheet example project,…and let's call it list examples.…I'm going to delete the print line statement.…There are two ways to create a list in Scala.…We can create the list in the same way that we do…when we create an array,…or we can use the cons operator.…
Let's take a look at both.…I'm going to declare a variable called l,…and it's equal to a list, I use a capital L for List,…and in parentheses, I put in my values.…So maybe we have a double, we have an int,…and we have a character.…Next, I'm going to use the cons operator.…I can also create a list, let's call it l2,…and this is equal to,…I'm going to use the values one through five.…So I use the cons operator, which is two colons.…So I can do one, two, three, four, and five.…
Remember, I need to indicate that I'm done,…
Join Peggy Fisher as she helps get you started with Scala, so you can leverage the unique capabilities it offers. First, learn the basics of type inference, variables, loops, functions, and operators. Then, find out how to read files using a console, perform pattern matching, handle exceptions, and more. Finally, learn how to use classes, fields, methods, and objects.
- Integrating with IDEs
- Scala worksheets
- Scala repl sessions
- Type inference
- Creating variables
- Working with loops
- Higher-order functions
- Scala operators
- Working with decision statements
- Handling exceptions using try or catch
- Working with tuples and arrays
- Classes, fields, and methods
Skill Level Intermediate
Java Platforms Compared: SE vs EE vs MEwith Peggy Fisher25m 38s Intermediate
Scala Essential Training for Data Sciencewith Dan Sullivan1h 51m Intermediate
1. Getting Started with Scala
2. Scala Basics
3. More Scala Basics
4. Objects with Scala
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.