Skip to content

Instantly share code, notes, and snippets.

@clevertrevor
Created February 25, 2019 15:57
Learn Kotlin Inline Functions in 3 Minutes #2
val list = listOf('a', 1) // list with a Char and an Int
// both print 'a'
println(list.filter( { it is Char} )) // inline call site
println(list.filterNotInline( { it is Char} )) // not-inline call site
// copy of library function with inline keyword removed
fun <T> Iterable<T>.filterNotInline(predicate: (T) -> Boolean): List<T> {
return filterTo(ArrayList<T>(), predicate)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment