you have to declare some generic type `doMove<S...
# announcements
k
you have to declare some generic type
doMove<Something>
which isn't even used
u
Haven't tried, but how about:
Copy code
KClass<out T>? = null as KClass<Queen?>)
l
Yes, will try it right now
k
@uli this is not type safe
l
Ok. So I forget about this solution
k
what if you call
doMove<King>()
and don't pass a class?
there's a reason this is not compiling
u
i did not try. traveling on a train currently ­čśë
k
please don't to this, you will run into type issues
l
Ok. I forget about nullable way
u
or simply use this oveload:
Copy code
fun doMove(startSquare: Pair<Int, Int>, endSquare: Pair<Int, Int>): ChessGame {
    doMove(startSquare, endSquare, null as KClass<Queen>)
}
l
Thanks, but I did rather go into the following
Copy code
fun doMove(startSquare: Pair<Int, Int>, endSquare: Pair<Int, Int>): ChessGame{
        return doMove(startSquare, endSquare, Queen::class)}

fun <T> doMove(startSquare: Pair<Int, Int>, endSquare: Pair<Int, Int>, promotionPiece: KClass<out T>): ChessGame where T: ChessPiece, T: Promotable {