Learn how to add decision making in your Scala programs. Decisions usually take the format of if (some condition) then perform some action. Sometimes, this also includes code for when the condition is false.
- (Voiceover) All programming languages need code…that allows us to test for possible situations…and then choose a branch of code accordingly.…Let's create a new worksheet and walk through some examples.…I'm going to add a new worksheet…and I will call it "decisions."…At the very top of the worksheet,…I'm going to start by declaring a variable.…Let's have a variable that represents the day of the week.…So let's call it "today"…and let's set it equal to Monday.…
Next, what I want to do is I want to test…the variable, today. If it is Monday,…then I want to print out one message.…If it's not Monday, then I want to print out…a different message.…So I'm going to say, "if,"…and then I'm going to use my variable name,…"today equals equals," and I'm going to check and see…if it is equal to Monday.…If it is, I just want to print out a message,…so I'm going to do a print line…and I'm going to say, "It might rain."…Now that's fine, and if it is equal to Monday,…it'll print that out, so we can go ahead and save this,…and we'll see, because it is set to Monday,…
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?
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.