Scala is a language that join both worlds “Functional Programming” and “Object Oriented”.
We talked a little bit about “Functional Programming” in the previous SKBs and today we are going to introduce the basics for “Object Oriented” : the classes and more specifically how to create an instance of a class.
We will be diving a bit more into the theory after the exercise.
class is a collection of functions that can be reused. This collection is created with parameters and that will make the
instance of the class behave differently.
In a lot of programming books, you will see a
class being described as a “blueprint”. And using this “blueprint”, you are able to “instantiate”, or build, an
The way to build a class in Scala is using the keyword
To summarize all the terminology:
new: The keyword used in Scala to instantiate a class and make an object.
valcontained in the
def(functions) contained in the