5/7/2023 0 Comments Generic kotlin![]() All runtimes need to erase types at some level. Sealed class UserDataAppResult : AppResult() Ĭurrently UserDataAppResult.Error is not found which makes sense.īut is it possible to reuse the AppResult sealed class hierarchy and introduce new types. Thats a relatively minor syntax issue, fixable with something like Kotlin. Gain a high-level introduction to more Kotlin concepts such as generics, enum classes, data classes, objects, and scope functions which youll be using in. which can be accessed using different types. ![]() ![]() The most common examples are extensions for collections: List, Map, and Set. Generics are the powerful features that allow to define classes, methods, and properties etc. Is it possible to use the AsyncResult class below to prevent redefining InFlight, Error and InFlight in UserDataAppResult and CreateUserResult? //TODO: use this to make the below classes generic?ĭata class Error(val errorMessage: String) : AsyncResult()ĭata class Loaded(val users: T) : AsyncResult() Generic extension functions When we are writing utility functions, often we want them to be generic.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |