<How to restrict enums in Kotlin?> I have an enum ...
# stackoverflow
u
How to restrict enums in Kotlin? I have an enum with many values; error codes for example, or some official list of coded values. In my application, I have several functions where only a subset of those values is admissible. How can I derive restricted enums that contain only a subset of the original enum? For example, I have an externally provided dictionary of error codes that model as enum: enum class APIError(val: errorCode: Int) { INCORRECT_CHARACTER(1), MISSING_VALUE(2), TOO_SMALL(3), TOO_LARGE(4) } In one...