Skip to content

Commit 8e1e0a6

Browse files
fhammerschmidtzth
authored andcommitted
Add docs for Arra.joinWith / joinWithUnsafe
1 parent 1df6ce2 commit 8e1e0a6

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/Core__Array.resi

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,30 @@ let indexOfOpt: (array<'a>, 'a) => option<int>
384384
@send external indexOfFrom: (array<'a>, 'a, int) => int = "indexOf"
385385

386386
/**
387-
`joinWith(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Under the hood this will run JavaScript's `toString` on all the array items.
387+
`joinWith(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Array items must be strings, to join number or other arrays, use `joinWithUnsafe`. Under the hood this will run JavaScript's `toString` on all the array items.
388+
389+
## Examples
390+
```rescript
391+
let array = ["One", "Two", "Three"]
392+
393+
Console.log(array->Array.joinWith(" -- ")) // One -- Two -- Three
394+
```
395+
*/
396+
@send
397+
external joinWith: (array<string>, string) => string = "join"
398+
399+
/**
400+
`joinWithUnsafe(array, separator)` produces a string where all items of `array` are printed, separated by `separator`. Under the hood this will run JavaScript's `toString` on all the array items.
388401
389402
## Examples
390403
```rescript
391404
let array = [1, 2, 3]
392405
393-
Console.log(array->Array.joinWith(" -- ")) // 1 -- 2 -- 3
406+
Console.log(array->Array.joinWithUnsafe(" -- ")) // 1 -- 2 -- 3
394407
```
395408
*/
396409
@send
397-
external joinWith: (array<'a>, string) => string = "join"
410+
external joinWithUnsafe: (array<'a>, string) => string = "join"
398411
@send external lastIndexOf: (array<'a>, 'a) => int = "lastIndexOf"
399412
let lastIndexOfOpt: (array<'a>, 'a) => option<int>
400413
@send external lastIndexOfFrom: (array<'a>, 'a, int) => int = "lastIndexOf"

0 commit comments

Comments
 (0)