Skip to content

Instantly share code, notes, and snippets.

@devrath
Created September 30, 2022 15:44
Show Gist options
  • Select an option

  • Save devrath/897c72497271badb6ee2ce48a4c8235e to your computer and use it in GitHub Desktop.

Select an option

Save devrath/897c72497271badb6ee2ce48a4c8235e to your computer and use it in GitHub Desktop.
Sealed class implementation
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
println(User.Name)
println(User.Age)
}
}
16026-16026 System.out com.droid.code I com.droid.code.User$Name@eafcd60
16026-16026 System.out com.droid.code I Age
sealed class User {
object Name : User()
data object Age : User()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment