|
|
|
|
|
by Boldened15
466 days ago
|
|
Sorry I don't get the example, are both code blocks meant to be client-side code? > It acknowledges the reality that a non-exhaustive enum isn’t really an enum. It’s just a list of things that people might type into that field. I would say the opposite, the kinds of enums that map a case to a few hardcoded branches (SUCCESS, NETWORK_ERROR, API_ERROR) are often an approximation of algebraic data types which Rust implements as enums [0] but not most languages or data formats. Since often using those will require something like a `nullthrows($response->getNetworkError())` once you've matched the enum case. The kind of enum that's just a string whitelist, like flavors or colors, which you can freely pass around and store, likely converting it into a human-readable string or RGB values in one or two utils, is the classic kind of enum to me. [0] https://doc.rust-lang.org/std/keyword.enum.html |
|