There are a lot of cases when you need to make a decision in a program based on some condition or value. The first thought which comes to mind is IF ELSE operator or something like SWITCH in Java. But Scala offers more powerful and elegant approach for handling of such situations. Let's consider how pattern matching can help you.
I enrolled to Functional Programming in Scala specialization on Coursera. It consists of 5 courses which will take around 180 days. First course in the specialization is Functional Programming Principles in Scala. I already completed the first week and learned some stuff about recursive functions. So It's time to share some knowledge.
That's not a secret that Scala is very popular programming language in BigData industry. And you may heard before that Scala is a data-centric programming language. This means not more, that with its help you can work with a data more easier comparing with other languages. Important roles in this play two Scala features: case classes and case objects.
For a long time I couldn't understand currying functions in Scala and how they work. That was really horrible! Because occasionally I met the currying functions in the code and wasted too much time to read them. So finally I decided to learn how it works and where could be applied.
Now after we have considered basics of Scala functions, we can make a next step in more complex use cases functional programming. Since functions in Scala are objects we can pass them as arguments in another functions, also we can return them as a result. In this article I'm going to examine multiple examples of higher-order functions.
Scala combines two programming paradigms: object oriented and functional. As a result you get best from the two worlds. From the one side you can describe models as objects, from the other side you can apply functions to them. And as you may guess, it's really awesome! Let's discover today basics of Scala functions.
How a newcomer can understand Akka's principles of work? Couple of examples from the documentation could be not enough. From the other side, a simple application which shows Akka in action is a very good way for demonstration of Actors capabilities. So let's start the acquaintance with the simple Akka use case!