You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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