Skip to content

Commit 87d6b0d

Browse files
committed
Add buffer library
1 parent 369e845 commit 87d6b0d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/Runtime Environment/Buffer.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
The buffer class — available via `require` — is a fast intermediate storage for incrementally-constructed strings.
2+
3+
---
4+
### `buffer.new`
5+
6+
Creates a new buffer instance.
7+
8+
---
9+
### `buffer.append`
10+
11+
Appends a string to a buffer instance.
12+
13+
#### Parameters
14+
15+
1. The buffer instance.
16+
2. The string to append.
17+
18+
---
19+
### `buffer.tostring`, `__tostring`
20+
21+
Converts the buffer into a string.
22+
23+
#### Parameters
24+
25+
1. The buffer instance.
26+
27+
#### Returns
28+
29+
A string.
30+
31+
```pluto
32+
local buffer = require "pluto:buffer"
33+
34+
local buff = new buffer()
35+
buff:append("Hello,")
36+
buff:append(" world!")
37+
print(buff) --> Hello, world!
38+
```

0 commit comments

Comments
 (0)