aboutsummaryrefslogtreecommitdiff
path: root/doc/docs/pt-br/doc/attributes.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/docs/pt-br/doc/attributes.md')
-rw-r--r--doc/docs/pt-br/doc/attributes.md46
1 files changed, 46 insertions, 0 deletions
diff --git a/doc/docs/pt-br/doc/attributes.md b/doc/docs/pt-br/doc/attributes.md
new file mode 100644
index 0000000..e6fd5a7
--- /dev/null
+++ b/doc/docs/pt-br/doc/attributes.md
@@ -0,0 +1,46 @@
1# Attributes
2
3Syntax support for Lua 5.4 attributes. And you can still use both the `const` and `close` declaration and get constant check and scoped callback working when targeting Lua versions below 5.4.
4
5```yuescript
6const a = 123
7close _ = <close>: -> print "Out of scope."
8```
9<YueDisplay>
10
11```yue
12const a = 123
13close _ = <close>: -> print "Out of scope."
14```
15
16</YueDisplay>
17
18You can do desctructuring with variables attributed as constant.
19
20```yuescript
21const {:a, :b, c, d} = tb
22-- a = 1
23```
24<YueDisplay>
25
26```yue
27const {:a, :b, c, d} = tb
28-- a = 1
29```
30
31</YueDisplay>
32
33You can also declare a global variable to be `const`.
34
35```yuescript
36global const Constant = 123
37-- Constant = 1
38```
39<YueDisplay>
40
41```yue
42global const Constant = 123
43-- Constant = 1
44```
45
46</YueDisplay>