From f5267545355d2b56cf19346579b29749b76ec0b9 Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Fri, 19 Jun 2020 01:52:21 +1000 Subject: [PATCH] docs: update wording & fix typo --- doc/docs.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index c9a0eebd3e..4fae90b7f8 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -1194,23 +1194,25 @@ There are 3 ways to access the cast variant inside a match branch: fn unary_expr(ux UnaryExpr) {...} fn if_expr(ix IfExpr) {...} - // using `it` + // using `it` match expr { BinaryExpr { binary_expr(it) } ... } - // using the shadowed variable, in this case `expr` + // using the shadowed variable, in this case `expr` match expr { UnaryExpr { unary_expr(expr) } ... } - // using `as` so specify a variable + // using `as` to specify a variable match expr as actual_expr { IfExpr { if_expr(actual_expr) } ... } ``` +Note: shadowing only works when the match expression is a variable. It will not work on struct fields, arrays indexing, or map key lookup. + ## Option/Result types and error handling ```v