Operator Inside Match Statement

Godot Version

4.3

Question

I was writing code and trying to use a match statement when checking again two values.

match item_id:
	> other_item_id:
		pass
	== other_item_id:
		pass

I get an error on both lines for Expected expression for match pattern, I was wondering if there is a way to write a match to handle code like this, or if I would have to use an If statement?

I know I could do if item_id > other_item_id and if item_id == other_item_id but would like to do match statements if possible as I prefer them for code readability and repetition reasons.

Thanks.

This is not really how you use pattern matching. You normally want to test for equality.
Heres the docs, maybe you’ll find something you can use

1 Like

Thank you! I hadn’t been able to find the docs on match statements before as searching ‘match’ in the built-in docs doesn’t show it annoyingly.

Yeah theres one site for all the syntax basically

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.