Starting to Program

It's time to write our first program. For this we're going to use a Scala worksheet. Worksheets make is very easy to run short programs, so are ideal for our first adventures in programming. (For longer programs we usually write code a different way, but we'll worry about that when we get to it.)

To create a worksheet:

You might find it easier to follow along with the video.

INSERT VIDEO

Now we have the worksheet setup we can write our first program. Type in

1 + 2

and then save the worksheet. The worksheet will run your program and you should see the file change to read

1 + 2 // : Int = 3

This may take a little while the first time you save it. It will be much faster on subsequent saves.

This very simple program provides an example of all the concepts we'll discuss in the remainder of the chapter:

We'll learn about those next, but I encourage you to play around with the worksheet right now before moving on.