Skip to content

Instantly share code, notes, and snippets.

@alexbezhan
Created May 15, 2012 07:53
Show Gist options
  • Save alexbezhan/2699837 to your computer and use it in GitHub Desktop.
Save alexbezhan/2699837 to your computer and use it in GitHub Desktop.
Play japid break in for loop
`for Ingredient ingredient: ingredients
`ingredient.product.get();
`if (_index < 4 || ingredients.size() == 4) {
`${ingredient.product.name}
`} else if (_index == 4){
<li>...</li>
`} else {
`break;
`}
`
@mayan31370
Copy link

You can use "return" instead, but do remember there must be no space between the "}" and "return".
for Ingredient ingredient: ingredients` ingredient.product.get(); ``if (_index < 4 || ingredients.size() == 4) {
${ingredient.product.name}` } else if (_index == 4){

  • ...
  • ``} else {
    ``return;}`

    @branaway
    Copy link

    Currently break does not work in open for loops, neither does continue. The return hack in the above sample works like a "continue".

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment