scala - How do I break out of a play framework template loop? -


given loop in template this:

@for(item <- items) {        @if(item.id == 42) {             break     } }    

how can make break? break/continue construct available use in play framework template?

assuming items scala collection, idiomatic approach not break, filter out elements don't want process before start iterating.

i'm guessing collection ordered id, , intention stop once item 42. if indeed case, i'd go this:

@for(item <- items.filter(_.id < 42)) {   // stuff } 

Comments

Popular posts from this blog

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -

Change the color of an oval at click in Java AWT -