如何从Any数组检查和访问adViewClass?

val adViewClass = AddViewClass(name = "an instance")
val elements = listOf("trevor", "john", adViewClass, "0goo")

如何从列表中获取该adViewClass

最佳答案

您可以使用简单的elementAt获得类(class)

elements.elementAt(2)



并使用is检查类(class)
if (obj is AdViewClass) {

08-04 22:25