Union types

I would argue the kotlin way of representing this would be something like this:

sealed class RecursiveMap<R, T> {
    class Data<R, T>(val data: T): RecursiveMap<R, T>()
    class Container<R, T>(private val map: Map<R, RecursiveMap<R, T>>) : RecursiveMap<R, T>(), Map<R, RecursiveMap<R, T>> by map
}
1 Like