Skip to content

Commit 09dedc1

Browse files
committed
Document universal block opener
1 parent 383194b commit 09dedc1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Pluto allows `do` to be used as a universal block opener, meaning it can be used instead of `then` and `begin`.
2+
```pluto title="If Statement Example"
3+
local x = 3
4+
if x == 3 do
5+
print("x is 3!")
6+
end
7+
```
8+
```pluto title="Class Statement Example"
9+
class Human do
10+
function __construct(public name) end
11+
function greet() print($"Hello, {self.name}!") end
12+
end
13+
new Human("John"):greet()
14+
```
15+
```pluto title="Enum Statement Example"
16+
enum Suit do
17+
HEARTS,
18+
DIAMONDS,
19+
CLUBS,
20+
SPADES
21+
end
22+
assert(HEARTS == 1)
23+
```

0 commit comments

Comments
 (0)