I have a sealed class declared as follows:
sealed class SealedClass {
object Pizza: SealedClass()
data class Hamburger(val hasCheese: Boolean): SealedClass()
}
I have a map that maps SealedClass keys to String values and I would like to retrieve a particular string whenever I access the SealedClass.Pizza key within the map, but the result of accessing the SealedClass.Pizza entry returns null when I attempt to use a SealedClass.Pizza key that I construct in a different segment of my code.
The SealedClass.Pizza objects produced seem to have different hashes, which would probably explain why this is the case. Printing them results in
SealedClass$Pizza@4cf4ae53
and SealedClass$Pizza@21773412
I was under the impression that objects were the same across all instances of a class, so I don't know why they have different hashes, but regardless, I would like to be able to use both of these SealedClass.Pizza
objects to access the same string. How might I do this?