You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
GDScript: Allow variables in match patterns
To restore an ability available in 3.x and reduce compatibility changes.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
func test():
|
||||
var a = 1
|
||||
match 1:
|
||||
a:
|
||||
print("reach 1")
|
||||
|
||||
var dict = { b = 2 }
|
||||
match 2:
|
||||
dict.b:
|
||||
print("reach 2")
|
||||
|
||||
var nested_dict = {
|
||||
sub = { c = 3 }
|
||||
}
|
||||
match 3:
|
||||
nested_dict.sub.c:
|
||||
print("reach 3")
|
||||
|
||||
var sub_pattern = { d = 4 }
|
||||
match [4]:
|
||||
[sub_pattern.d]:
|
||||
print("reach 4")
|
||||
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
reach 1
|
||||
reach 2
|
||||
reach 3
|
||||
reach 4
|
||||
Reference in New Issue
Block a user