Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 406bcd5

Browse files
committed
Revert "Undocument now-deprecated export modifier"
This reverts commit df5c6ad.
1 parent c4c300e commit 406bcd5

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

docs/New Features/Export Modifier.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
The `export` modifier allows you to automatically aggregate things you want to export into a table.
5+
6+
```pluto title="Old Code"
7+
local version = 2
8+
9+
local function add(a, b)
10+
return a + b
11+
end
12+
13+
return {
14+
version = version,
15+
add = add
16+
}
17+
```
18+
19+
```pluto title="New Code"
20+
export version = 2
21+
22+
export function add(a, b)
23+
return a + b
24+
end
25+
```
26+
27+
The return statement is automatically generated at the end of the block, so it is not limited to the top-level function:
28+
29+
```pluto
30+
package.preload["test"] = function()
31+
export version = 2
32+
33+
export function add(a, b)
34+
return a + b
35+
end
36+
37+
-- end of scope; 'return' is automatically generated
38+
end
39+
40+
print(require"test".version)
41+
```
42+
43+
## Using Compatibility Mode?
44+
45+
You may need to use `pluto_export` instead of `export`. Alternatively, `pluto_use export` will enable the keyword independently of environment settings.

0 commit comments

Comments
 (0)