What is the difference between 'val' and 'lazy val' in Scala? What is Eager Evaluation? What is Lazy Evaluation?
Answer / Amit Singh Bisht
In Scala, 'val' is a value that is initialized when it is defined. This process is known as Eager Evaluation. On the other hand, 'lazy val' initializes the value only when it is first accessed or needed. This is called Lazy Evaluation.
| Is This Answer Correct ? | 0 Yes | 0 No |
Is scala good for data science?
What is an abstract class in scala?
What is the difference between call-by-value and call-by-name function parameters?
Explain the use of tuples in scala?
What is akka in scala?
Why is scala faster than java?
What is the difference between :: and #:: in Scala? What is the difference between ::: and #::: in Scala?
What are higher-order functions in scala?
What is a function literal in scala?
What do you mean by option in scala and why it is used?
What is a flatmap in scala?
What is method overloading in scala?