July 2018
Intermediate to advanced
400 pages
12h 14m
English
A large portion of the Kotlin standard library’s functionality is defined via extension functions and extension properties.
For example, take a look at the source code file Strings.kt (note: Strings, not String), by pressing the Shift key twice to open the Search Everywhere dialog and entering “Strings.kt”:
public inline fun CharSequence.trim(predicate: (Char) -> Boolean): CharSequence { var startIndex = 0 var endIndex = length - 1 var startFound = false while (startIndex <= endIndex) { val index = if (!startFound) startIndex else endIndex val match = predicate(this[index]) if (!startFound) { if (!match) startFound = true else startIndex += 1 } else { if (!match) break else endIndex -= 1 ...Read now
Unlock full access