Named parameters allow us to be explicit about naming arguments when they are passed to a function. This has the benefit that, for functions with many parameters, explicit naming makes the intent of each argument clear. This makes the call site more readable.
In the following example, we check to see whether the first string contains a substring of the second:
val string = "a kindness of ravens" string.regionMatches(14, "red ravens", 4, 6, true)
This example will take the a kindness of ravens substring from 14 to 20, and will check that it is equal to the red ravens substring from 4 to 10. If that is confusing, then it is certainly easy to forget which parameter goes where. Therefore, if we could prefix the parameter with the name, it would be far more readable.
To use named parameters, we put the parameter name before the argument...