Hello, I have a question regarding sealed classes ...
# announcements
d
Hello, I have a question regarding sealed classes + data classes: I'm trying to do this, but it warns me that Data class inheritance from other classes is deprecated. And I think that precissely in this case you would probably always want immutable data classes, that are checked for exhaustiveness in when clauses.
Copy code
sealed class XmlElement {
	data class OpenCloseTag(val name: String, val attributes: Map<String, String>) : Element()
	data class OpenTag(val name: String, val attributes: Map<String, String>) : Element()
	data class CloseTag(val name: String) : Element()
	data class Text(val text: String) : Element()
}
In other languages like haxe, you would have something like this, that is even more concise (you don't have to use val or extending anything):
Copy code
enum XmlElement {
	OpenCloseTag(name: String, attributes: Map<String, String>)
	OpenTag(name: String, attributes: Map<String, String>)
	CloseTag(name: String)
	Text(text: String)
}