-
-
Save anonymous/216d66ea8d26a6cf6f35b532a6b0f07a to your computer and use it in GitHub Desktop.
Demonstrates scoping of variables inside and out of a loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set itlist = ['alpha', 'betta', 'gamma', 'delta', 'echo'] %} | |
{% set str = 'started--' %} | |
{% for item in itlist %} | |
{% set str = str ~ item %} | |
{% if not loop.last %} | |
{% set str = str ~ ', ' %} | |
{% endif %} | |
print str during loop for item {{ item }}: | |
test.configurable_test_state: | |
- name: added item {{ item }} | |
- changes: False | |
- result: True | |
- comment: {{ str }} | |
{% endfor %} | |
str after loop: | |
test.configurable_test_state: | |
- name: str after loop | |
- changes: False | |
- result: True | |
- comment: {{ str }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment