There are two main types of decisions in Scala, the if statement and the match expression. Learn about how they work by watching this video.
- [Instructor] There are two main types…of decisions in Scala.…We have the if statement, and we have a match expression.…Probably the more common of the two is the if statement,…which is really if some expression is evaluated as true,…a Boolean expression, then execute some code.…We can have a nested if, or we can even have…an if and an else.…Let's take a look at an example…that uses an if statement inside of a method.…We'll create a method to calculate…an hourly employee's earnings.…
So what do I need to check for in my if statement?…If you said whether the employee works 40 hours or more,…you're absolutely correct.…So when you're calculating payroll,…if an employee works more than 40 hours,…they usually get time and a half for any overtime.…So that's what we're going to go with,…but let's start by creating some variables.…We'll create one to hold the hours worked by the employee,…and let's just set it to 40 to start.…And we need to know their hourly rate,…so I'll create a variable called rate,…and let's set that equal to 10 dollars.…
- 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?
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.