From 752f5ef2ca92fae51cd299b7e6301684f2b95e91 Mon Sep 17 00:00:00 2001 From: monabot Date: Wed, 9 Aug 2023 20:27:35 +0000 Subject: [PATCH] feat(docs): update docs Updates the Wing docs. See details in [workflow run]. [Workflow Run]: https://github.com/winglang/docsite/actions/runs/5813749072 ------ *Automatically created via the "update-docs" workflow* Signed-off-by: monabot --- .../version-latest/03-language-reference.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/versioned_docs/version-latest/03-language-reference.md b/versioned_docs/version-latest/03-language-reference.md index 0d3915aea..12206349a 100644 --- a/versioned_docs/version-latest/03-language-reference.md +++ b/versioned_docs/version-latest/03-language-reference.md @@ -2,6 +2,7 @@ title: Wing Programming Language Reference id: language-reference description: The Wing Language Reference +sidebar_label: Language Reference keywords: [Wing reference, Wing language, language, Wing language spec, Wing programming language] --- @@ -1543,11 +1544,18 @@ f(1, 2, field1: 3, field2: 4); // f(1, 2, field1: 3); // can't do this, partial expansion is not allowed ``` -#### 3.6.3 Roadmap - -The following features are not yet implemented, but we are planning to add them in the future: - -* Variadic arguments (`...args`) - see https://github.com/winglang/wing/issues/125 to track. +#### 3.6.3 Variadic Arguments +When a function signature's final parameter is denoted by `...` and annotated as an `Array` type, +then the function accepts typed variadic arguments. +Inside the function, these arguments can be accessed using the designated variable name, +just as you would with a regular array instance. +```TS +let f = (x: num, ...args: Array) => { + log("${x + args.length}"); +}; +// last arguments are expanded into their array +f(4, 8, 15, 16, 23, 42); // logs 9 +``` [`▲ top`][top]