Peggy Fisher demonstrates her solution to creating Scala code to store a list of key value pairs using the Map class.
- [Instructor] Welcome back.…How did you make out with this challenge?…I hope you were able to successfully create…a Map object that contains the mapping…of movies to their ratings.…Let me show you how I would approach this problem.…I'm going to start by creating a variable called movies.…And this will hold my Map…of all the different movies and their ratings.…So this is going to be equal to,…I'm going to use the Map class,…so I use a capital M,…and I'm going to list my movie title, Finding Nemo,…and then I use my right-facing arrow,…and I specify the rating for that movie.…
Finding Nemo is rated G.…Next I'll do Finding Dory,…which is another movie that is rated PG.…So this time I'm going to do "PG".…Next I'm going to add the movie Men In Black,…and this movie is actually rated PG-13.…And the last movie I'm going to add to my list is The Avengers.…And The Avengers is also rated PG-13.…
All right, so I'm mapping the movie to the ratings.…Now, if I wanted to get the rating for a particular movie,…I could do that as well.…
- Installing Scala
- Integrating with IDEs
- Creating variables
- Using special functions
- Basic types and operations
- Tuples, sets, maps, arrays, and lists
- Classes, fields, and methods
- Singleton objects
Skill Level Intermediate
1. Why 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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.