diff options
Diffstat (limited to 'doc/docs/pt-br/doc/attributes.md')
| -rw-r--r-- | doc/docs/pt-br/doc/attributes.md | 46 |
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 | |||
| 3 | Syntax 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 | ||
| 6 | const a = 123 | ||
| 7 | close _ = <close>: -> print "Out of scope." | ||
| 8 | ``` | ||
| 9 | <YueDisplay> | ||
| 10 | |||
| 11 | ```yue | ||
| 12 | const a = 123 | ||
| 13 | close _ = <close>: -> print "Out of scope." | ||
| 14 | ``` | ||
| 15 | |||
| 16 | </YueDisplay> | ||
| 17 | |||
| 18 | You can do desctructuring with variables attributed as constant. | ||
| 19 | |||
| 20 | ```yuescript | ||
| 21 | const {:a, :b, c, d} = tb | ||
| 22 | -- a = 1 | ||
| 23 | ``` | ||
| 24 | <YueDisplay> | ||
| 25 | |||
| 26 | ```yue | ||
| 27 | const {:a, :b, c, d} = tb | ||
| 28 | -- a = 1 | ||
| 29 | ``` | ||
| 30 | |||
| 31 | </YueDisplay> | ||
| 32 | |||
| 33 | You can also declare a global variable to be `const`. | ||
| 34 | |||
| 35 | ```yuescript | ||
| 36 | global const Constant = 123 | ||
| 37 | -- Constant = 1 | ||
| 38 | ``` | ||
| 39 | <YueDisplay> | ||
| 40 | |||
| 41 | ```yue | ||
| 42 | global const Constant = 123 | ||
| 43 | -- Constant = 1 | ||
| 44 | ``` | ||
| 45 | |||
| 46 | </YueDisplay> | ||
