Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- Coroutines
- GitHub
- Rxjava
- Gradle
- livedata
- 프로그래머스
- textfield
- pandas
- Coroutine
- MyVoca
- relay
- MiTweet
- Compose
- Codeforces
- activity
- Hilt
- ProGuard
- TEST
- Python
- androidStudio
- 코루틴
- 암호학
- boj
- Kotlin
- 쿠링
- architecture
- AWS
- android
- 코드포스
- 백준
Archives
- Today
- Total
목록enum (1)
이동식 저장소
[Kotlin] sealed class vs. enum class
Kotlin을 처음 배울 때는 enum class와 sealed class를 혼동하곤 했다. enum을 구현할 떄 enum class 대신 sealed class를 써도 되지 않나? 결론 sealed class를 써도 되지만, 바람직한 사용법은 아니다. 왜? enum class가 왜 적합한지는 설명 안 해도 되겠지? 이제 sealed class의 바람직한 사용 예시를 설명하려 한다. sealed class는 클래스가 정의된 블럭 안에서만 상속될 수 있으며, 외부에서의 상속을 허용하지 않는다. sealed class Animal { // Animal은 이 안에서만 상속될 수 있다. class Cat: Animal class Dog: Animal } ..
Primary/Kotlin
2022. 7. 7. 14:14