In C++ we can get the abstract key/value type (key_type
, value_type
, http://en.cppreference.com/w/cpp/container/map) from the defined map. This is quite convenient when I need to change the map type later since the dependent type would change accordingly.
In Scala I'm also looking for such a feature. For example, I define a map type:
type MapTy : mutable.Map[Long, Int]
And I hope to return an entry of the map (whose type is Long->Int
). The return type depends on MapTy
and it had better be explicitly specified in the function signature, written as something like MapTy::key_type->MapTy::value_type
. Therefore, when later I change MapTy
to
type MapTy : mutable.Map[Int, Int]
The entry type would also change to Int->Int
simultaneously.
Is it possible in Scala?