From 927a8851aea72c2e0098845f70e2ffc05d6b3345 Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Thu, 15 Nov 2018 21:27:02 +0330 Subject: [PATCH] BAEL-2374: Added a simple reified generic example. --- core-kotlin/src/main/kotlin/com/baeldung/generic/Reified.kt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 core-kotlin/src/main/kotlin/com/baeldung/generic/Reified.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/generic/Reified.kt b/core-kotlin/src/main/kotlin/com/baeldung/generic/Reified.kt new file mode 100644 index 0000000000..37a632fe41 --- /dev/null +++ b/core-kotlin/src/main/kotlin/com/baeldung/generic/Reified.kt @@ -0,0 +1,6 @@ +inline fun Iterable<*>.filterIsInstance() = filter { it is T } + +fun main(args: Array) { + val set = setOf("1984", 2, 3, "Brave new world", 11) + println(set.filterIsInstance()) +} \ No newline at end of file