January 2018
Intermediate to advanced
434 pages
14h 1m
English
The prefix to the extension function (the name that comes before the dot) is called receiver type, that is, the type being extended. This receiver object is accessed inside the function using the this keyword. The extension functions are resolved statically; it's like calling a static method. Since this is a static method, it's not needed to be defined under the class, but since it's a static method, it's hard to test. For example, Mockito (a testing framework) cannot test static methods, so to produce great code quality, use extension function only if that function doesn't require any testing.
Read now
Unlock full access