You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parameters:
- name: loctype: [ Location ]description: The location to check.
instead of using int and linking to the enum in the description:
parameters:
- name: loctype: [ int ]description: The [Location](/api/enums/Location) to check.
This means the signature of Card.IsLocation in the site would be displayed as Card.IsLocation(Card c, Location loc) instead of Card.IsLocation(Card c, int loc).
Pros:
The allowed values are formalized and summarized nicely. Can also help static analyzers narrow down erroneous values.
No need to redundantly link to the enum in the description, especially if the enum's name gets mentioned more than once. (Related: shorthand for linking to api entries)
Cons:
Could confuse people expecting an "enum" to represent all allowed values when used as a type. For example, in the case of the Location enum, you could actually pass a combination of LOCATION_ constants, e.g. LOCATION_MZONE|LOCATION_SZONE.
The text was updated successfully, but these errors were encountered:
I don't think it's a good idea to use enums as types then not display them as such. Sort of defeats the purpose.
I think it does make sense to display them as types which extend int to avoid your concern of confusion.
You could create a type / extend the enum to allow for certain operations like '+' or '|'
afaik, there's no enum that can be used in combination of a value defined in another enum.
but if there is, it could be defined as new type combining the enums with allowed operations.
Should Enums be usable as Types? e.g.:
instead of using
int
and linking to the enum in the description:This means the signature of
Card.IsLocation
in the site would be displayed asCard.IsLocation(Card c, Location loc)
instead ofCard.IsLocation(Card c, int loc)
.Pros:
Cons:
LOCATION_
constants, e.g. LOCATION_MZONE|LOCATION_SZONE.The text was updated successfully, but these errors were encountered: