You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
I often iterate over enums and dictionaries, and would love to benefit from the introduction of functional features in the same way that I do with arrays.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
As per title, I'm proposing that map and filter be implemented for that any type x that's accepted in a for i in x line of code.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
enum E {FIRST, SECOND, THIRD}
var d = {E.FIRST: 1, E.SECOND: 2, E.THIRD: 3}
func _ready():
print(E.\
filter(func(e): return e!=E.SECOND).\
map(func(e): return d[e] * 2))
OUTPUT: [2, 6]
If this enhancement will not be used often, can it be worked around with a few lines of script?
Equivalent code to the one in my example would be:
enum E {FIRST, SECOND, THIRD}
var d = {E.FIRST: 1, E.SECOND: 2, E.THIRD: 3}
func _ready():
var result = []
for key in d:
if key!=E.SECOND:
result.append(d[key] * 2)
print(result)
OUTPUT: [2, 6]
which is more verbose (the functional version could be even leaner if the lambdas didn't require an explicit return keyword, but that topic should probably go in its own feature proposal), uses an auxiliary variable, and personally feels less readable.
Is there a reason why this should be core and not an add-on in the asset library?
As it has to do with the syntax of GDScript it would be cleaner and more consistent for this to be core.
The text was updated successfully, but these errors were encountered:
Describe the project you are working on
A 2D match-3 game.
Describe the problem or limitation you are having in your project
I often iterate over enums and dictionaries, and would love to benefit from the introduction of functional features in the same way that I do with arrays.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
As per title, I'm proposing that map and filter be implemented for that any type
x
that's accepted in afor i in x
line of code.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
Equivalent code to the one in my example would be:
which is more verbose (the functional version could be even leaner if the lambdas didn't require an explicit return keyword, but that topic should probably go in its own feature proposal), uses an auxiliary variable, and personally feels less readable.
Is there a reason why this should be core and not an add-on in the asset library?
As it has to do with the syntax of GDScript it would be cleaner and more consistent for this to be core.
The text was updated successfully, but these errors were encountered: