Skip to content

Commit 2b04101

Browse files
committed
io.unique
1 parent 96be310 commit 2b04101

File tree

1 file changed

+16
-0
lines changed
  • docs/Runtime Environment

1 file changed

+16
-0
lines changed

docs/Runtime Environment/IO.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,19 @@ else
207207
print("chmod is not available on this platform.")
208208
end
209209
```
210+
211+
---
212+
### `io.unique`
213+
Generate a unique file name by appending a number when a conflict occurs.
214+
#### Parameters
215+
1. The base file name without extension.
216+
2. The file extension.
217+
#### Returns
218+
A string representing a file name that does not already exist.
219+
```pluto
220+
-- assuming index.pluto exists
221+
print(io.unique("index", "pluto")) --> index (2).pluto
222+
```
223+
```pluto
224+
print(io.unique("file_that_doesnt_exist", "pluto")) --> file_that_doesnt_exist.pluto
225+
```

0 commit comments

Comments
 (0)