Frage

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)?

War es hilfreich?

Lösung

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)
} 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top