Is there a trick to get use `T?` in a place where ...
# announcements
m
Is there a trick to get use
T?
in a place where you need
T
? Unfortunately there’s no
T!
😄 Alternatively in a function where I want a non-nullable
T
for
reified T: Any?
. Basically
T & Any
.
n
Constrain TFoo to Any?
m
Not possible in my context. Let’s take the function with reified parameter example. That’s easier 🙂 Let’s say I need a
typeOf
of non-null
T
without reflection, but
T
must be nullable in the same function.
r
Then constrain
T
to
Any
and use
T?
in the function
m
That would always make it nullable, which is not desired. T may or may not be nullable.
l
What is
Nothing?!
? 😄
1
m
Just like everywhere else in Kotlin - something that you could construct that that throws a neat exception if you try to use it 😛
l
Or just
while (true) { }