August 2017
Intermediate to advanced
440 pages
10h
English
Sometimes we want only to pass a value for the last argument. Let's suppose that we want to define a value for a suffix, but not for a prefix and inBracket (which is defined before the suffix). Normally, we would have to provide values for all previous parameters including the default parameter values:
printValue("str", true, true, "!") // Prints: (str)
By using named argument syntax, we can pass specific arguments using the argument name:
printValue("str", suffix = "!") // Prints: (str)!
This allows very flexible syntax, where we can supply only chosen arguments when calling a function (that is, the first one and the second from the end). It is often used to specify what this argument is because such a call is ...
Read now
Unlock full access