Carvel Logo

For loop

Refer to Starlark for loop specification for details.

  • iterating with values
array:
#@ for i in range(0,3):
- #@ i
- #@ i+1
#@ end
  • iterating with index
array:
#@ arr = [1,5,{"key":"val"}]
#@ for i in range(len(arr)):
- val: #@ arr[i]
  index: #@ i
#@ end 
  • use of continue/break
array:
#@ for i in range(0,3):
#@   if i == 1:
#@     continue
#@   end
- #@ i
- #@ i+1
#@ end

(Help improve our docs: edit this page on GitHub)