it works with `Any` if its not a `List`
# announcements
p
it works with
Any
if its not a
List
a
your problem is with type erasure and generic types
also you cant check for
is List<Audi>
for the same reason
x
You will get close with reification
a
i mean, inside an
if
condition
x
Copy code
inline fun <reified T>createColorsResources(carModel: List<T>): String {
    return when {
        T::class == Audi::class -> "audi"
        else                    -> "not audi"
    }
}
Copy code
fun main(args: Array<String>) {
    println(createColorsResources(listOf(Audi())))
    println(createColorsResources(listOf(Audi(), NotAudi())))
    println(createColorsResources(listOf(NotAudi())))
}
class Audi
class NotAudi
p
oh
that would work Im not sure if its worth tho : )
would have to refactor a bit since my function is overrided I belive it cannot be done like that
Also I cannot access the class properties (which is smth I need)
return when { T::class == Audi::class -> carVariable.speed else -> "not audi" }
like in classic 'is' case : P
x
what's carVariable in this case?
p
instance of argument passed to func or smth
carModel*