Summarizing the major books on the language
-
Scala Options Explained (YouTube)
-
Scala Futures: In the Scala Standard Library, a Future is a data structure used to retrieve the result of some concurrent operation. This result can be accessed synchronously (blocking) or asynchronously (non-blocking). I will be focusing on the non-blocking futures.
Case classes are used to conveniently store and match on the contents of a class. You can contruct them without using new
scala> case class Cars(brand: String, model: String)
defined class Cars
scala> val tesla1 = Cars("Tesla", "Model-S")
tesla1: Cars = Cars(Tesla,Model-S)
Case classes automatically have equality
scala> val tesla2 = Cars("Tesla", "Model-S")
tesla2: Cars = Cars(Tesla,Model-S)
scala> tesla1 == tesla2
res0: Boolean = true
Getting started Scala and Akka
Tutorial: Asynchronous Programming With Akka Actors
Concurrency and Fault Tolerance Made Easy: An Akka Tutorial with Examples
What is an Actor in Akka? An actor is essentially nothing more than an object that receives messages and takes actions. It is decoupled from the source of the message and its only responsibility is to recognize the type of message and take action accordingly.
What type of actions?
- Execute some operations itself (such as performing calculations, persisting data, calling an external web service, and so on)
- Forward the message, or a derived message, to another actor
- Instantiate a new actor and forward the message to it
Akka Demo: count words from text file
Reactive Messaging Patterns explained
This repository contains exercises, hints, and answers for the book Functional Programming in Scala
The apply method is the scala version of a constructor
e.g in the class StringOps
def apply(n: Int): Char
"Hello".apply(4) == "o"
"Hello"(4) == "o"
An upper type bound T <: A declares that type variable T refers to a subtype or equal to type A
The lower-bound operator T >: A, restricting types to those that are equal to or are extended by the given type T.
example in Scala Option class:
`final def getOrElse[B >: A](default: => B): B = if (isEmpty) default else this.get`