-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Enum.valueOf
shouldn't be called using an Enum.name
property. Since the name of the enum variants may change over time, this might constitute a runtime-only error. This is most suspicious when a different enum's name is being used as the argument. e.g.
val model = CarModel.CIVIC
val make = CarMake.valueOf(model.name)
Dealing with the enum variants more directly (like switching on the enum variant) comes with more compile-time guarantees (especially in Kotlin). Conversion between enums with similar variants should happen with these switching constructs rather than depending on the similarity of enum variant names.
Metadata
Metadata
Assignees
Labels
No labels