https://kotlinlang.org logo
Title
e

elizarov

02/20/2018, 11:47 AM
@sabag.ronen
reified
in Kotlin only reifies classes, but it does not reify types. Now
String
and
String?
are different types, but they have the same class.
👍 1
🤔 1
s

snrostov

02/20/2018, 8:32 PM
@sabag.ronen
inline fun <reified T> isNullable() = null is T
should work
👏 1
but it does not reify types
@elizarov this is working for me (Kotlin 1.2):
inline fun <reified T> isNullable() = null is T

fun main(args: Array<String>) {
  println(isNullable<String>())
  println(isNullable<String?>())
}
false
true
s

sabag.ronen

02/20/2018, 8:37 PM
@snrostov you are right, it is working!!!!!!😀 Thanks a lot
s

snrostov

02/20/2018, 8:52 PM
It turns out this hack is already mentioned here https://youtrack.jetbrains.com/issue/KT-15992#comment=27-2652752 😀
s

sabag.ronen

02/20/2018, 8:56 PM
I have looked at this issue today and somehow missed it… Once again thanks