Skip to content

Commit 60697a3

Browse files
authored
Merge pull request eugenp#5692 from alimate/BAEL-2374
BAEL-2374: Added a simple reified generic example
2 parents 42fac5d + 927a885 commit 60697a3

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • core-kotlin/src/main/kotlin/com/baeldung/generic
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
inline fun <reified T> Iterable<*>.filterIsInstance() = filter { it is T }
2+
3+
fun main(args: Array<String>) {
4+
val set = setOf("1984", 2, 3, "Brave new world", 11)
5+
println(set.filterIsInstance<Int>())
6+
}

0 commit comments

Comments
 (0)