You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
GDScript: Implement pattern guards for match statement
Within a match statement, it is now possible to add guards in each
branch:
var a = 0
match a:
0 when false: print("does not run")
0 when true: print("but this does")
This allows more complex logic for deciding which branch to take.
This commit is contained in:
@@ -2415,6 +2415,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
|
||||
"return",
|
||||
"match",
|
||||
"while",
|
||||
"when",
|
||||
// These keywords are not implemented currently, but reserved for (potential) future use.
|
||||
// We highlight them as keywords to make errors easier to understand.
|
||||
"trait",
|
||||
@@ -2448,6 +2449,7 @@ bool GDScriptLanguage::is_control_flow_keyword(String p_keyword) const {
|
||||
p_keyword == "match" ||
|
||||
p_keyword == "pass" ||
|
||||
p_keyword == "return" ||
|
||||
p_keyword == "when" ||
|
||||
p_keyword == "while";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user