https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
h

hallvard

10/06/2018, 2:43 PM
I am struggling to port some older code from a jvm-only project to combined jvm/js. One of my classes was extending java.util.HashMap, which is now impossible, of course, as the kotlin HashMap is a final class. Seems I have two options: 1) implement Map and add
entries()
,
keys()
,
size()
,
containsKey()
etc or 2) remove class inheritance and reduce the map to a backing field. Or did I miss something? (Hoping so. Would like to change as little as possible.)
o

oshai

10/06/2018, 6:18 PM
Maybe a class delegation, depends what you want to do
Implement map that way
g

gildor

10/07/2018, 8:30 AM
Maybe you could use delegation for this and delegate all calls to MutableMap, so it would be multiplatform solution
h

hallvard

10/07/2018, 8:36 AM
I'm not using delegation, although that wouldn't be all that different. I'll pick up this thread again if I choose to use delegation!