How to make a open class to sealed class in kotlin

Viewed 58

I have this below class, and I would like to make it a sealed class. How can I do it, and how to access this class from other classes?

open class Toy (var type: Type, var name : String) {

    open val source: String = ""

}

I can make it sealed class as below but how to Instantiate it?

   sealed class Toy (var type: Type, var name : String) {
    
        open val source: String = ""
    
    }
0 Answers
Related