https://kotlinlang.org logo
#announcements
Title
# announcements
w

william

08/11/2019, 11:26 PM
are there any built in sealed classes that accepts any primitive?
im looking to create a map of string to a "primitive" and its rather gross to create my own sealed class and have wrapper objects for those primitve types
k

karelpeeters

08/11/2019, 11:34 PM
Not as far as I know, probably because Kotlin tries to avoid the concept of a primitive as much as possible, that's why there's no
int
vs
Integer
.
w

william

08/12/2019, 2:35 AM
yeah i knew that was a thing just too bad i'll have to wrap it then
g

gildor

08/12/2019, 5:24 AM
Sealed class for any primitives? How should it work? There is no common type for all primitives, you can create own sealed class that wraps them all, but looks as too specific use case for me to be in stdlib
And even in theory on JVM you cannot create generic collection for multiple primitive types, it will be boxed in any case. Tho collection itself maybe a generic of some other type, for example sealed class which contains field with primitive generic
w

william

08/13/2019, 3:36 AM
i assumed so but figured i would ask