https://kotlinlang.org logo
#getting-started
Title
# getting-started
d

Dontsu

09/21/2023, 1:24 AM
Copy code
override fun <T : ViewModel?> create(
    key: String,
    modelClass: Class<T>,
    handle: SavedStateHandle
): T & Any {
    TODO("Not yet implemented")
}
I've never seen that kind of type
T & Any
until now. What does the
&
mean in this generic type? Does it have just common
&
meaning? or a bit operator?
v

Vampire

09/21/2023, 1:37 AM
T
and
Any
, so definitely not null
it's a special case of intersection types
d

Dontsu

09/21/2023, 1:46 AM
Thank you guys! :)
s

Stephan Schröder

09/22/2023, 1:59 PM
not only a special case of intersection types, but also the only case (
& Any
) implemented so far.