Created
September 30, 2022 15:44
-
-
Save devrath/897c72497271badb6ee2ce48a4c8235e to your computer and use it in GitHub Desktop.
Sealed class implementation
This file contains hidden or 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
| class MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| println(User.Name) | |
| println(User.Age) | |
| } | |
| } |
This file contains hidden or 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
| 16026-16026 System.out com.droid.code I com.droid.code.User$Name@eafcd60 | |
| 16026-16026 System.out com.droid.code I Age |
This file contains hidden or 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() | |
| data object Age : User() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment