Since Java 8 I don't use switch case anymore for Java. I find it much more readable to create a functional interface, and add it to the enum. For example if you have an enum with different types of messages, and you want to correct topic for that type depending on some TopicConfiguration class. You can add a lambda config -> config.emailTopic to all the enums. Reducing it to just a single function call on the enum when needed.
In Rust there not even is enum, there is match which is more powerful. And you can use traits to get the same kind of construction as described for Java.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Since Java 8 I don't use switch case anymore for Java. I find it much more readable to create a functional interface, and add it to the enum. For example if you have an enum with different types of messages, and you want to correct topic for that type depending on some TopicConfiguration class. You can add a lambda
config -> config.emailTopic
to all the enums. Reducing it to just a single function call on the enum when needed.In Rust there not even is enum, there is match which is more powerful. And you can use traits to get the same kind of construction as described for Java.