Daniel Lyons' Notes

match in GDScript

Equivalent to switch in many other languages.

Docs

Difference from switch in other languages

Crash-course for people who are familiar with switch statements

  1. Replace switch with match.
  2. Remove case.
  3. Remove any breaks.
  4. Change default to a single underscore.

Syntax

match <test value>:
	<pattern(s)>:
		<block>
	<pattern(s)> when <pattern guard>:
		<block>
	<...>
match in GDScript
Interactive graph
On this page
Docs
Difference from switch in other languages
Crash-course for people who are familiar with switch statementsLink to this heading
Syntax