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 |
What is a function literal in scala?
Tell the advantages of companion objects when used in scala?
Why is an option used in scala?
What is a closure?
What is a flatmap in scala?
What is the difference between a java future and a scala future?
What is Case Classes?
What is vector in scala collection?
What is the main motto of Scala Language?
What is throw in scala?
What is an ofdim method in scala?
Difference between Scala’s Inner class and Java’s Inner class?