that’s disappointing
# announcements
that’s disappointing
Yeah, but unfortunately there's no way around it, it's a JVM thing (type erasure if you google it).
just took a moment for it to click for me
sorry for the noise!
for what it's worth, it is actually possible with
(on JVM)
Copy code
assertIs<Array<Int>>(arrayOf(1, 2, 3)) // pass
assertIs<Array<String>>(arrayOf(1, 2, 3)) // fail
due to the historical fact that array "class" has had a special representation since the beginning of Java
I think I’ll still update my assertion to take a mandatory class argument
not generic enough to implement generics on, so we ended up with type erasure for everything else for compatibility
so it’s clear to the caller that it’s only the actual class is guaranteed to be matched, not its type parameters
yeah…. type erasure was new when I was in college
I remember people grousing about it
yep, that would be reasonable
I'm not sure if Kotlin/JS even bothers to keep a distinction between List and Array though
also, contracts are nifty!
I’m not sure if Kotlin/JS even bothers to keep a distinction between List and Array though
I wouldn’t be surprised either way
it does some things that are a little surprising if you’re interacting with kotlin/js-generated code from pure js, in order to maintain the state that kotlin expects!
Yeah, I remember finding this very rough in certain contexts when I first discovered it
I remember wanted to do a union on some classes I didn't control, so you need to use a sealed class, but you can't use the classes you don't control directly in the union because you can't make them inherit. So I just had a toy class to hold one member; i wanted to make it generic, but all this just doesn't work out because of type erasure. So you have to write a "holder" class separate for every type you want in the union