2 ms·
Bear in mind that in both Java and Kotlin you can statically import enum entries: import foo.SomeEnum.MIDNIGHT setThreadLevel(MIDNIGHT) In practice,
by mike_hearn 2y ago
Bear in mind that in both Java and Kotlin you can statically import enum entries:
import foo.SomeEnum.MIDNIGHT
setThreadLevel(MIDNIGHT)
In practice, you write out ThreatLevel.MIDNIGHT, let the IDE import it for you, and then use an IDE hotkey to do the static import and eliminate the prefix.
- jwells89 2y agoThis is true, with the caveat that your imports don’t share member names in common (e.g. you can’t static import two “medium” members, one from SpiceLevel and the other from PizzaSize). Swift doesn’t have this restriction, at least as far as enums are concerned.