A tuple is formed by enclosing values inside parentheses: val v =(1, 1.4, "Hello"). All values in a Map are actually tuples containing single pairs. Pairs are the smallest case of tuples.
- [Instructor] When working with a map collection…we saw that each element in the map…was a key value pair.…It had two values inside each pair.…In Scala we have a term for this type of pairing.…It's called a tuple.…Pairs are the smallest case of tuples.…Tuples can actually be created with anywhere from…two to 22 values inside parentheses.…Let's create a worksheet…so we can take a look at some tuples.…I'm going to right click on my SRC package…and go to new Scala worksheet.…
And I'm just going to call it tuple examples.…I'm going to delete the print line statement.…Now let's add a tuple.…So I'm going to declare it as a val…and I'll call it v is equal to.…And a tuple can contain, like I said…two to 22 different values.…So let's create one that has three values.…It doesn't have any different name in Scala…so an element that has two values is called a tuple…and an element that has 22 values is still called a tuple.…As you can see in this example…I have three different data types.…
I have an integer, a double and a string.…
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.