/2.kt
Created
February 25, 2019 15:57
Learn Kotlin Inline Functions in 3 Minutes #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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