Question

The documentation has an example of using map

@products.map { p =>
  @display(product = p)
} 

Can I use fold like?

@productOpt.fold(
  <em>-<em>
){ p =>
  @display(product = p)
} 

How should I arrange the code in the template (the above example does not work)?

Was it helpful?

Solution

You can use fold. I think your problem is the parenthesis. Did you try with curly brackets?

@productOpt.fold{
  <em>-</em>
}{ p =>
  @display(product = p)
} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top