<@U5G56CL87> Yes - from my understanding it will w...
# codereview
g
@antoin_m Yes - from my understanding it will work as expected with the type simply as the Vec sealed class. No extra casting is needed. The compiler will correctly show the “exhaustive check” if you add another data class.
Copy code
operator fun Double.times(vec: Vec) = when (vec) {
    is Vec2 -> vec.copy(this * vec.x, this * vec.y)
    is Vec3 -> vec.copy(this * vec.x, this * vec.y, this * vec.z)
}
a
Yeah but then it returns a
Vec
and not a
Vec2
or
Vec3