Arguments
When declaring a function, you may declare arguments inside the parentheses, each separated by a comma. The arguments must be preceded by a dollar sign. They become variables inside the function. When the function is called, it expects values to be passed that will fill the arguments in the order declared.
Arguments, by default, copy the passed value into the local variable. If the variable is preceded by the & operator, the variable instead becomes an alias for the passed variable. This is commonly referred to as a variable reference. Changes made to referenced variables change the original.
To demonstrate this idea, imagine we wanted a function that stripped commas from numbers. That way if we got something like "10,000" from an input ...
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