October 2019
Intermediate to advanced
434 pages
11h 54m
English
Infix functions are functions defined with the infix keyword, which allows them to be called using the infix notation. Infix notation is best demonstrated using an example. The following example demonstrates the usage of the to infix function:
"userId" to "1234"
The to function is part of the Kotlin standard library and returns Pair.
The implementation of this type of function is very similar to that of any other function. In the following snippet, we can see the implementation of the to function:
/** * Creates a tuple of type [Pair] from this and [that]. * * This can be useful for creating [Map] literals with less noise, for example: * @sample samples.collections.Maps.Instantiation.mapFromPairs */public infix fun <A, B> ...
Read now
Unlock full access