May 2019
Beginner to intermediate
466 pages
10h 44m
English
The functions that require a long list of arguments can be hard to use, as the programmer has to remember the order and the types of the expected values. For such cases, we can define functions that accept labeled arguments instead. These are called keyword arguments.
In order to define functions that accept keyword arguments, we need to add a semicolon after the function's list of unlabeled arguments and follow it with one or more keyword=value pairs. We actually encountered such functions in Chapter 11, Creating Our First Julia App, when we used Gadfly to plot the Iris flower dataset:
plot(iris, x=:SepalLength, y=:PetalLength, color=:Species)
In this example, x, y, and color are all keyword arguments.
The definition of ...
Read now
Unlock full access