Ellipsis (computer programming): Difference between revisions

Content deleted Content added
Ruud Koot (talk | contribs)
copyedit
Line 29:
 
== Variable number of parameters ==
 
===C and C++===
{{unreferenced section|date=January 2011}}
In the [[C (programming language)|C programming language]], an ellipsis is used to represent a [[variadic function|variable number of parameters]] to a [[function (programming)|function]]. For example:
Line 46 ⟶ 48:
 
[[C++0x]] introduces templates with a [[variadic template|variable number of arguments]].
 
===PHP===
 
PHP 5.6 will<ref>https://wiki.php.net/rfc/variadics</ref> support use of ellipsis to define an explicitly [[variadic function]], where <code>...</code> before an argument in a function definition means that arguments from that point on will be collected into an array. For example:
 
<source lang="php">
function variadic_function($a, $b, ...$other) {
return $other;
}
 
var_dump(variadic_function(1, 2, 3, 4, 5);
</source>
 
Produces this output:
 
array(3) {
[0]=>
int(3)
[1]=>
int(4)
[2]=>
int(5)
}
 
== Multiple dimensions ==