Good day, I am trying to use a sealed class to rep...
# getting-started
t
Good day, I am trying to use a sealed class to represent ViewHolder types in an Android project, with associated types similar to Swift. I have something like this:
Copy code
sealed class ItemType {
   object Header: ItemType()
  data class CartItem(val cart: Cart): ItemType() 
}
I would like these to map to an Int for the RecyclerView ViewType. It works okay with the object since it has a hashCode, but when doing a when for the CartItem there is no ordinal/hashCode. Anybody have an example of doing something like this? A quick google search did not turn up anything. Thank you!