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.
Aclassis a collection of functions that can be reused. This collection is created with parameters and that will make theinstanceof the class behave differently.
In a lot of programming books, you will see aclassbeing described as a “blueprint”. And using this “blueprint”, you are able to “instantiate”, or build, anobject.
The way to build a class in Scala is using the keywordnew.
To summarize all the terminology:
new.new: The keyword used in Scala to instantiate a class and make an object.valcontained in theclass.def(functions) contained in theclass.fieldandmethod.