Variadic Functions is an actively used design pattern. In mathematics and in computer programming, a variadic function is a function of indefinite arity, i.e., one which accepts a variable number of arguments. Support for variadic functions differs widely among programming languages.. Read more on Wikipedia...

?Years Old

Languages with Variadic Functions include c, go, php

Example from c:

double average(int count, ...)

Example from go:

// This variadic function takes an arbitrary number of ints as arguments.
func sum(nums {
  fmt.Print("The sum of ", nums) // Also a variadic function.
  total := 0
  for _, num := range nums {
    total += num
  fmt.Println(" is", total) // Also a variadic function.

Example from php:

function sum(...$nums)
    return array_sum($nums);
echo sum(1, 2, 3); // 6

Last updated August 9th, 2020

Edit Variadic Functions on GitHub