mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-03 05:48:42 +03:00
Add typed loop variable example in GDScript reference (#9388)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user