Scala provides an interesting feature of importing different classes from the same package by using {} clause. If we wan to import classes PersonDto and WorkerDto from package com.waitingforcode.dto, ...
Overriding fields and properties in Scala is straightforward. To do that we can simply use the override keyword. However, it doesn't apply for the case when the superclass needs the overridden values ...
Loops are widely used in programming. We use them to iterate through the elements of one collection or to implement a sorting algorithm like in the following snippet: behavior of "priority queue"...
Thanks to the withDefault(...) method, Scala has a very easy practical and easy way to define the default value for a key not present in the map. Unfortunately, the sequences don't benefit from this b...
Scala's collection have a lot of interesting methods like grouped, take and drop. Another one that I didn't know was sliding. It behaves like a sliding window, i.e. it always takes X elements where th...
Mapping Scala's sequence elements is easy when the mapping logic is the same for all items. However, sometimes you may want to apply different transformation to the first or the last element of the li...
We have 2 sequences. Each of them contains the columns that should be used to make a JOIN between 2 different tables in a database. How to create this query with Scala? First, we'll need a function...
Often case classes represent the data moved further in the pipeline. For example, they can represent JSON data that will be written into your data warehouse storage or an RDBMS. If for whatever rea...
There are multiple ways to do that. You can of course extends Function1[Input, Output] (let's focus only on unary functions). Actually, there is also another, more idiomatic manner to write a function...