BAEL-2374: Added a simple reified generic example.

This commit is contained in:
Ali Dehghani 2018-11-15 21:27:02 +03:30
parent 42fac5dbcf
commit 927a8851ae
1 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1,6 @@
inline fun <reified T> Iterable<*>.filterIsInstance() = filter { it is T }
fun main(args: Array<String>) {
val set = setOf("1984", 2, 3, "Brave new world", 11)
println(set.filterIsInstance<Int>())
}