Skip to content

Add match pattern guard comparison example#12155

Closed
Leonardo-Ma wants to merge 1 commit into
godotengine:masterfrom
Leonardo-Ma:patch-1
Closed

Add match pattern guard comparison example#12155
Leonardo-Ma wants to merge 1 commit into
godotengine:masterfrom
Leonardo-Ma:patch-1

Conversation

@Leonardo-Ma

Copy link
Copy Markdown

It's slightly confusing already by using an array match with wildcard to present a new concept. Not being obvious that it can be used for simple direct comparison.

@Leonardo-Ma
Leonardo-Ma requested review from a team as code owners July 17, 2026 03:01
@HolonProduction

Copy link
Copy Markdown
Member

using an array match with wildcard to present a new concept

Array patterns were introduced prior to this though.

IMHO introducing concepts with contrived examples is bad practice. What you added here is contrived. point is an array in this codeblock, so checking it with > makes no sense. Also all other branches do an actual real world check on the point while this one just makes no sense.

@Leonardo-Ma

Copy link
Copy Markdown
Author

I meant specifically the pattern guard and when keyword being introduced using an array and wildcard. Had to see examples elsewhere to actually understand what was happening.
Though I do agree the new examples are wrong. Also couldn't use it in my specific case where I wanted a simple match comparison instead of several ifs. It seems that's just not possible.

@Leonardo-Ma
Leonardo-Ma deleted the patch-1 branch July 21, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants