From c6946ca162911036a19cc7c5deadb6d8c127755e Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 14 Jul 2022 03:42:21 +0800 Subject: update doc and changelog. --- doc/docs/doc/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'doc') diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index ef00c23..90cb309 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md @@ -2343,19 +2343,23 @@ for item in *items You can use default values to optionally destructure the table for some fields. ```moonscript -item = x: 100 +item = {} + +{pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos') switch item - when {:x, :y = 200} - print "Vec2 #{x}, #{y}" -- table matching will pass + when {pos: {:x = 50, :y = 200}} + print "Vec2 #{x}, #{y}" -- table destructuring will still pass ```
-item = x: 100
+item = {}
+
+{pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos')
 
 switch item
-  when {:x, :y = 200}
-    print "Vec2 #{x}, #{y}" -- table matching will pass
+  when {pos: {:x = 50, :y = 200}}
+    print "Vec2 #{x}, #{y}" -- table destructuring will still pass
 
-- cgit v1.2.3-55-g6feb