Example #1: Read from a list & write to a list Java Way in Scala
Example #1: Read from a list & write to a list Java Way in Scala
100+ FAQ Scala interview questions answered with code. Learn more about FP – 6 tips to transforming your thinking from OOP/imperative programming to functional programming (i.e. FP). Scala is very …
This extends Coding Scala Way – Part 1 Example #4: FP using both recursion and functional combinator like foldLeft Can you write the following code written in Java the Scala way? …
This extends Q1 – Q5 Scala Functional Programming basics interview questions & answers
Q6. What is a curried function in Scala?
A6. Currying is the technique of transforming a function with …
Example #6: Lazy initialization & evaluation of code Scala support “views”, which are collections that can be lazily evaluated. One use for views is when you need to traverse a collection …
Q13. What are the different approaches in Scala to solve the following task?
Given numbers 1 to 6, and you need to extract out the odd numbers and double them, and …
Nulls in Scala is a code smell, and a better way to handle null values is with an “Option“, which has 2 sub …
Q19. What is the use of Tuples in Scala?
A19. A Tuple is an immutable collection that can hold objects of different types. In other words, it groups together logical …
Can you explain the Scala concepts applied in the following code snippets?
Java has idioms like Try-Catch-Finally, Scala has idioms like 1) “Option-Some-None”, 2) Either-Left-Right 3) Try-Success-Failure.
Q27. How does Scala try to solve the problem of getting rid of null values & …
Example #14: Reduce operations Given a list of functions as shown below, how will you go about applying all the functions in the list to each input number and sum the …
Q33. What is a “Future” object in Scala? Is it an immutable object? A33. A Future is a holder object that holds a value (i.e. success scenario) or an exception (i.e. …
Example #16: Regular Expression Regular expression (aka regex) to identify numbers in a string. Invoking “findFirstIn” and “findAll” functions of the “Regex” class. “[0-9]+”.r is a short form instead of instantiating …