Example #1: Read from a list & write to a list
Java Way in Scala
1 2 3 4 5 6 7 8 9 10 11 12 13 |
object ListToList extends App { val inputList = List("Java", "Scala", "Ruby") val outputList = scala. |
Java Way in Scala
1 2 3 4 5 6 7 8 9 10 11 12 13 |
object ListToList extends App { val inputList = List("Java", "Scala", "Ruby") val outputList = scala. |
Q1. What is a pure function?
A1. A pure function is a function where the following conditions are met:
1) The Input solely determines the output.
2) The function does not change its input.
3) The function does not do anything else except computing the output. This means NO I/O, which is no reading from database, file or input console & no writing to a database, file or output console.…
This extends Coding Scala Way – Part 1 Can you write the following code written in Java the Scala way? Java coding question on recursion and generics Q. Can you…
Login Register 100+ Free Java interview FAQs 100+ Free Big Data interview FAQs
This extends Scala Functional Programming basics – pure functions, referential transparency, side effects, etc.
Q1. What is a first-class function?
A1. A first-class function is a function that can be treated like a value.
1) Can be assigned to a variable as a value can be assigned to a variable.…
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…
Login Register 100+ Free Java interview FAQs 100+ Free Big Data interview FAQs
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…
Login Register 100+ Free Java interview FAQs 100+ Free Big Data interview FAQs
Nulls in Scala is a code smell, and a better way to handle null values is with an “Option“, which has 2 sub classes “Some” that has a value and a “None” that does not have a value. Instead of checking for “myVal !=…
Let’s see how we can wire up functions with & without currying, and then touch on functional composition. Without currying Here are simple functions example that add, add10, multiply and…
Login Register 100+ Free Java interview FAQs 100+ Free Big Data interview FAQs
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…
Login Register 100+ Free Java interview FAQs 100+ Free Big Data interview FAQs