Aryan PrajapatKnowledge Contributor
What is a sealed class in Kotlin?
What is a sealed class in Kotlin?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Questions | Answers | Discussions | Knowledge sharing | Communities & more.
A sealed class in Kotlin is a class that can have a limited set of subclasses defined within it. It allows you to restrict the inheritance hierarchy and define a closed set of possible subclasses.
Sealed classes are useful when you want to represent a restricted type hierarchy, where all the possible subclasses are known in advance and should be handled exhaustively in when expressions.