solution and it didn't work because of inheritance. Well, I guess then the simple
is
solution is directly readable and I stick to this. Thanks for your efforts 🙂
s
Shawn
05/08/2018, 2:10 AM
the
when
solution was at least a little bit more concise
h
halirutan
05/08/2018, 3:07 AM
Ahh, damn. I don't use Slack that often and I haven't seen the direct reply. Thanks for throwing it into my face
s
Shawn
05/08/2018, 3:09 AM
haha, no worries dude
n
nil2l
05/08/2018, 7:11 AM
But this one works well with inheritance. No?
Copy code
val v = HashSet<String>()
listOf(String::class, Set::class).any { it.isInstance(v) }
k
karelpeeters
05/08/2018, 7:20 AM
But is that really better?
n
nil2l
05/08/2018, 7:40 AM
It’s shorter. Looks not good because of
::class
. And I don’t know if it will require kotlin-reflection as dependency.
As for problem I think it must be solved via common interface, and not if-is’s.