I guess something like Context but for general use...
# random
f
I guess something like Context but for general use
y
Can't you just use a map with constrained types? E.g.:
Copy code
fun <K: Command, V: Processor<K>> myMap(): Map<K, V>
f
That’s not type safe. Since the type of get(command) is Processor<?> since the signature of the get method of a regular map is get(K):V not
<E:K,R: Processor<E>> get(key:E): R
and put would have to be something like
<E:K, R: Processor<E>> put(k:E, v:R)
y
Ohhhh. You can wrap the Map in a data class that has E as the type parameter, and thus have safe get and set operators.
1