Created
September 30, 2022 16:05
-
-
Save devrath/599fda954df060ebf812ec9087e532b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class User { | |
object Name : User(){ | |
// We can override equals function | |
override fun equals(other: Any?): Boolean { return super.equals(other) } | |
// We can override hashCode function | |
override fun hashCode(): Int { return super.hashCode() } | |
// We can override toString function | |
override fun toString(): String { return super.toString() } | |
} | |
data object Age : User() { | |
val name : String = "Default" | |
// We can't override equals function | |
override fun equals(other: Any?): Boolean { return super.equals(other) } | |
// We can't override hashCode function | |
override fun hashCode(): Int { return super.hashCode() } | |
// We can override toString function | |
override fun toString(): String { return super.toString() } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment