Ellipsis (computer programming): Difference between revisions

Content deleted Content added
m Multiple dimensions: lang="numpy"
Line 45:
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:
 
:<{{code>|2=c|int printf( const char* format, ... );</code>}}<ref>http://www.cplusplus.com/reference/cstdio/printf/</ref>
 
The above function in C could then be called with different types and numbers of parameters such as:
 
:<{{code>|2=c|printf("numbers %i %i %i", 5, 10, 15);</code>}}
and
:<{{code>|2=c|printf("input string %s, %f", "another string", 0.5);</code>}}
 
[[C99]] introduced macros with a [[variadic macro|variable number of arguments]].<ref>[https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html Variadic Macros - Using the GNU Compiler Collection (GCC)]</ref>
Line 60:
 
As of version 1.5, [[Java (programming language)|Java]] has adopted this "varargs" functionality. For example:
:<{{code>|2=java|public int func(int num, String... strings)</code>}}
 
===PHP===
Line 75:
 
Produces this output:
<source lang="php">
 
array(3) {
[0]=>
Line 84:
int(5)
}
</source>
 
== Multiple dimensions ==