Skip to content

Commit

Permalink
docs: document about spreading arguments in sheet expr
Browse files Browse the repository at this point in the history
  • Loading branch information
iyxan23 committed Sep 20, 2024
1 parent befd978 commit 59ee74c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/sheet-how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,31 @@ spaces), you can do that by using double quotes:
> treated as strings. If you need to pass in a number, please also allow
> strings to be coerced into numbers, just like how `z.coerce.number()` works.
### Spreading Arguments

Sometimes, when you have an array and you need to spread it as its own separate
arguments. Let's say we have a function that returns an array of numbers, and
we need to sum them together with the sum function. But the problem is that the
sum function (its a builtin function) takes multiple arguments, not a single
array. Like so:

```
[sum 1 2 3 4 5]
```

We can make use of the spread operator `...` before the argument expression to
make it spread the array as each different arguments.

```
[sum ...[array 1 2 3 4 5]]
```

The experssion above will be interpreted as:

```
[sum 1 2 3 4 5]
```

### Types of expressions

There are essentially 5 different types of expressions:
Expand Down

0 comments on commit 59ee74c

Please sign in to comment.