In Play scala html template, one can specify
@(title: String)(content: Html)
or
@(title: String)(content: => Html)
What is the difference?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Writing
parameter: => Htmlis called a ‘by name parameter’.Example:
By name parameters are executed when used. The problem with this is that they can be evaluated more than once.
A good example would be an if statement. Let’s say if was a method like this:
It would be a waste to evaluate both
thenandelsebefore the method is executed. We know only one of the expressions will be executed, the condition is eithertrueorfalse. That’s the reasonwhenandelseare defined as ‘by name’ parameters.This concept is explained in the Scala course: https://www.coursera.org/course/progfun