Content deleted Content added
mNo edit summary |
|||
Line 171:
== Functions ==
Functions are defined by the special syntax <code>''return_type'' ''funcname''(''params'') { ''statement''; ''statement''; ... }</code>. Return to the calling function is denoted by the <code>return ''value'';</code> statement. Functions which do not return any value are denoted by the special return type <code>void</code>.
==Other syntax===
Square brackets (<code>[]</code>) are used for indexing into an array, as in: <code>''name''[''index'']</code>. (In most cases, the base index for arrays is 0, not 1).
In some languages, support for [[associative array]]s (also known as dictionaries) is implemented by the same syntax. For instance, in [[C++]]:
<source lang="cpp">
std::map<std::string, std::string> dict;
dict["foo"] = "bar";
dict["fred"] = "barney";
std::cout << dict["fred"] << std::endl;
</source>
== Typographical concerns ==
|