This video explores a powerful feature of Scala called pattern matching. Pattern matching allows us to compare a value or expression and process it accordingly using a sequence of alternatives called case statements. The case statements define a function that is invoked when there is a match.
- [Instructor] One of the really important features of Scala…is that it has pattern matching built in.…Pattern matching allows us to compare a value…or an expression and process it accordingly…using a sequence of alternatives called case statements.…The case statements define a function that is invoked…when there is a match.…The process of pattern matching is very similar…to what we see in a switch statement in Java.…Let's look at some examples.…I'm going to start by creating a function that will convert…a character from the English language and…it'll print out the corresponding Greek letter.…
So, for example, if I have an A, it'll be alpha.…So let's start by defining this.…And I'm just going to call it greekAlphabet.…And it's going to take in a letter.…And the letter's going to be a type character.…And this is equal to...…And in my function, I'm going to take this letter…and I'm going to try and match it.…So I'm going to use the match.…This is pattern matching now.…And inside the match, identify the cases…that I might encounter.…
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
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.