Merge pull request #5692 from alimate/BAEL-2374

BAEL-2374: Added a simple reified generic example
This commit is contained in:
Loredana Crusoveanu 2018-11-15 20:26:56 +02:00 committed by GitHub
commit 60697a321c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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>())
}