What is call-by-name? Does Scala and Java support call-by-name? What is the difference between call-by-value and call-by-name function parameters?
Answer / Shivaji Choudhary
Call-by-name is a parameter passing mechanism where an argument is passed as a reference to a subroutine, allowing the subroutine to evaluate the argument only when it is actually needed (i.e., the first time the argument's value is referenced inside the subroutine). Scala supports call-by-name through its by-name parameters, while Java does not have native support for call-by-name. The main difference between call-by-value and call-by-name is that call-by-value arguments are evaluated before being passed to a function (and then the result is passed), while call-by-name arguments are only evaluated when needed within the function.
| Is This Answer Correct ? | 0 Yes | 0 No |
How do you define a function in scala?
Explain operator and Explain types of operators in scala?
Does scala and java support call-by-name?
What is the difference between :: and #:: in Scala? What is the difference between ::: and #::: in Scala?
What is try catch in scala?
Explain que?
What is exception propagation in scala?
What is unapply method in scala?
What is 'Application' in Scala or What is Scala Application? What is 'App' in Scala? What is the use of Scala’s App?
Explain any five string methods?
Explain the scope provided for variables in scala.
Why is scala faster than java?