...

/

Optimizing an if Program

Optimizing an if Program

In this lesson, we will learn how to use Scala's features to optimize a program using an if expression. You will also be introduced to the else expression.

The previous lesson gave you a general overview of the if expression. In this lesson, our focus will be on how Scala allows you to write shorter code by consistently having result values.

Before we get started, let’s go over a couple of prerequisites for this lesson.

Input

The coding programs in this lesson require you to give input in order for them to execute successfully.

Before you press RUN, you must select the >_STDIN button located next to the RUN button which will provide an input field where you can type your input.

After you have typed the input, press RUN to execute the program.

Taking Input in Scala

Scala provides multiple methods that can be used to take ...