| Tip 11 | Distinguish Parameters and Arguments |
★2.7, 3.4+ A parameter (or, strictly speaking, a formal parameter) is what the function expects from the caller. Parameters are declared in the function header. Their values are not known until you call the function. The function should be ready to handle or reject any values. A parameter behaves as a local variable (Tip 76, Get the Hang of Local Variables).
An argument (or an actual parameter) is a value that the caller passes to the function. When you call a function, the arguments you pass become the formal parameters’ values as if you stealthily executed several assignment statements.
The two terms are often used interchangeably. I will use them interchangeably, too, as long as it does not ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access