[Bug #20482] [DOC] Clarify about pattern maching guard clause
Guard clauses can only be used in `case` pattern matching statements, not in `=>`/`in` operators.
This commit is contained in:
parent
5695c5df95
commit
b911d2222f
@ -422,7 +422,8 @@ These core and library classes implement deconstruction:
|
||||
|
||||
== Guard clauses
|
||||
|
||||
+if+ can be used to attach an additional condition (guard clause) when the pattern matches. This condition may use bound variables:
|
||||
+if+ can be used to attach an additional condition (guard clause) when the pattern matches in +case+/+in+ expressions.
|
||||
This condition may use bound variables:
|
||||
|
||||
case [1, 2]
|
||||
in a, b if b == a*2
|
||||
@ -450,6 +451,11 @@ These core and library classes implement deconstruction:
|
||||
end
|
||||
#=> "matched"
|
||||
|
||||
Note that <code>=></code> and +in+ operator can not have a guard clause.
|
||||
The following examples is parsed as a standalone expression with modifier +if+.
|
||||
|
||||
[1, 2] in a, b if b == a*2
|
||||
|
||||
== Appendix A. Pattern syntax
|
||||
|
||||
Approximate syntax is:
|
||||
|
Loading…
x
Reference in New Issue
Block a user