Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As you learned on the intermediate level how to use the set function, on this exercise we are going to put it into practice on the first line.

${set(count,0)}

And below it put the #{for comments} or #{for <VariableName>=CommentsCount} statement.

...

${set(count,%{${count} + 1})}

Let's put the mappings that we want to print on the template.

Author

${Comments[n].AuthorFullName}
Body${Comments[n].Body}

Now, We are going to use the function continue within a conditional block.

#{if (%{'${Comments[n].Body}'.equals('Hello Continue')})}

Jump to next comment.

#{continue}

#{end}

When the comment is equal to "Hello Continue", it is going to print the message "Jump the next comment" and the iteration goes to the start of the next comment.

Info

You must have comments on your issue and a comment with "Hello Continue".

After the conditional block with the continue statement, we are going to put another conditional block that only print prints the message "Next comment", when the count of our set funciton function is less than CommentsCount.

#{if (%{'${count}' < '${CommentsCount}'})}

Next comment.

#{end}

Finally, close the iteration comments with #{end}.

...

Let's put the mappings that we want to print on the template.

Author

${Comments[n].AuthorFullName}
Body${Comments[n].Body}

Now, We are going to use the function break with a conditional block.

#{if (%{'${Comments[n].Body}'.equals('Hello Stop')})}

Finish the iteration of comments.

#{break}

#{end}

When the comment is equal to "Hello Stop", it is going to print the message "Finish the iteration of comments" and the iteration stops, skipping to its end statement.

...

Info

If you like this exercise, please share your opinion on the page by just leaving a comment or a (thumbs up). Your opinion is very important for to us.

Thank you in advance.

Enjoy our product. (big grin)

Expand
titleClick here to see the Exercise 1 resources

Here's the Exercise 1 related files:

FileDescription
Exercise1Template

Exercise 1 Sample Template file

Exercise1GeneratedExercise 1 Sample generated file