Casting operator "as" as a method with type checking
I don’t really like the syntax of casting in Kotlin since it doesn’t play nice with chaining methods or require me with use “let”
someClass.getObject().let {it as SomeObject }
So I’ve created a method to replace this:
inline fun Any.asOrFail(): V = this as V
So now the code look something like that:
someClass.getObject().asOrFail()
But the problem is that this function doesn’t respect type boundary since it has no information on the type of “this”.
I was trying to do something like this...