5 Conditional constructs and loops

After reading this lesson, you’ll be able to

  • Control the execution of your code using an if-else construct
  • Iterate through instructions using while and for loops

In lesson 4, you learned how to define values and variables to store computation results. But life is not always so linear; when performing a task, you may also need to make informed decisions by selecting one approach rather than the other. In this lesson, you’ll discover how to combine different executions of your code through given conditions. You’ll learn how to use the most common conditional constructs and loops in Scala. You’ll use if-else constructs to check if the system should allow a requested operation in the capstone.

Consider this ...

Get Get Programming with Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.