Functions with Multiple Arguments
Use tuples to write functions with multiple arguments and results.
Now that we know about tuples, let’s see how we can use them in functions. In principle, there are two use cases:
- using tuples as the argument type of functions to write functions that take multiple parameters.
- using tuples as the return type of functions to write functions that have multiple results.
Tuples as arguments
Let’s write a function which computes the perimeter of a rectangle when given its two sides a
and b
:
Get hands-on with 1200+ tech skills courses.