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

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -