What is the difference between `class Foo<T>...
# getting-started
c
What is the difference between
class Foo<T>(val bar: T)
and
class Foo<T: Any>(val bar: T)
. I don’t understand what the
: Any
gets you…
n
It means that the type of
T
is a subtype of
Any
. That's useful because it means you can't use a nullable type (like
Int?
, for example)
If you have a collection of objects that are bounded with
Any
you know you will never have a null entry
m
In the first case, the implicit type of
T
is
Any?
5
c
Thanks!