Skip to content

Update variadic-functions concept docs#3062

Open
BNAndras wants to merge 1 commit intoexercism:mainfrom
BNAndras:update-variadic-functions-concept
Open

Update variadic-functions concept docs#3062
BNAndras wants to merge 1 commit intoexercism:mainfrom
BNAndras:update-variadic-functions-concept

Conversation

@BNAndras
Copy link
Copy Markdown
Member

@BNAndras BNAndras commented Apr 7, 2026

Related to #3042


If the type of the last parameter in a function definition is prefixed by ellipsis `...`, then the function can accept any number of arguments for that parameter.
Typically, functions accept only a fixed number of arguments.
Prefix the last parameter's type with `...` to accept any number of trailing arguments:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Prefix the last parameter's type with `...` to accept any number of trailing arguments:
However, if you prefix the last parameter's type with `...`, the function can accept any number of trailing arguments.
This makes the last parameter a _variadic parameter_.

The way variadic functions work is by converting the variable number of arguments to a slice of the type of the variadic parameter.

Here is an example of an implementation of a variadic function.
A function can have non-variadic parameters before the variadic one:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A function can have non-variadic parameters before the variadic one:
A function can have non-variadic parameters before the variadic one.
A function have at most one variadic parameter and it must be the last parameter.

@IsaacG IsaacG added x:action/improve Improve existing functionality/content x:module/concept Work on Concepts x:type/content Work on content (e.g. exercises, concepts) x:type/docs Work on Documentation x:size/medium Medium amount of work x:rep/medium Medium amount of reputation labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

x:action/improve Improve existing functionality/content x:module/concept Work on Concepts x:rep/medium Medium amount of reputation x:size/medium Medium amount of work x:type/content Work on content (e.g. exercises, concepts) x:type/docs Work on Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants