IssueRaiser

Add support for looping over dictionaries' key and value (`for key, value in dict`)

### Describe the project you are working on N/A ### Describe the problem or limitation you are having in your project Lots of time, you will have to iterate through a dictionary. Whether it be searching for something, querying, etc. As of currently, Godot only allow for a `for key in dict` loop. While you can do `var value = dict[key]`, this can get annoying if you deal with dictionaries a lot and have to look at the value. ### Describe the feature / enhancement and how it helps to overcome the problem or limitation The idea is that Godot will allow you to do ` for key,value in dict` type of loop to make it quicker to also look at the value. ### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams ```gdscript var dict = { "bruh": "moment", "one": "two", "two": "four", "four": "eight" } for key,value in dict: print(key, value) ``` ### If this enhancement will not be used often, can it be worked around with a few lines of script? It is impossible to modify how GDScript works using a plugin. ### Is there a reason why this should be core and not an add-on in the asset library? See above

Posted by atirutw on Oct 21, 2021, 2:14 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

support (Other)

Add support for looping over dictionaries' key and value (`for key, value in dict`)

atirutwOct 21, 2021, 2:14 PM

### Describe the project you are working on N/A ### Describe the problem or limitation you are having in your project Lots of time, you will have to iterate through a dictionary. Whether it be searching for something, querying, etc. As of currently, Godot only allow for a `for key in dict` loop. While you can do `var value = dict[key]`, this can get annoying if you deal with dictionaries a lot and have to look at the value. ### Describe the feature / enhancement and how it helps to overcome the problem or limitation The idea is that Godot will allow you to do ` for key,value in dict` type of loop to make it quicker to also look at the value. ### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams ```gdscript var dict = { "bruh": "moment", "one": "two", "two": "four", "four": "eight" } for key,value in dict: print(key, value) ``` ### If this enhancement will not be used often, can it be worked around with a few lines of script? It is impossible to modify how GDScript works using a plugin. ### Is there a reason why this should be core and not an add-on in the asset library? See above

Comments (0)

No comments yet. Start the discussion.

Comment on this issue