Introduction
Imperative vs. Declarative
Scala’s Approach
Introduction
Control structures can be thought of as blocks of code that determine or dictate the flow in which statements (lines of code) are executed; they basically control the flow of code. For instance, a block of code can flow in a sequential manner and there is a control structure that ensures its statements are executed sequentially. A block of code can also flow in an iterative manner and there are control structures that ensure its statements are executed iteratively.
Before we dive into Scala’s control structures, it’s important to first visit the programming paradigms; imperative and declarative.