Add typed loop variable example in GDScript reference (#9388)

This commit is contained in:
Muller-Castro
2024-08-01 21:30:20 -03:00
committed by GitHub
parent b389d1d6ed
commit a36ff907f9

View File

@@ -1588,6 +1588,10 @@ in the loop variable.
for x in [5, 7, 11]:
statement # Loop iterates 3 times with 'x' as 5, then 7 and finally 11.
var names = ["John", "Marta", "Samantha", "Jimmy"]
for name: String in names: # Typed loop variable.
print(name) # Prints name's content.
var dict = {"a": 0, "b": 1, "c": 2}
for i in dict:
print(dict[i]) # Prints 0, then 1, then 2.