Given the following enumeration in C # and the / case switch, to return the border color of the text field according to its state, for example.
enum TextboxState { Default, Error } switch(foo) { default: case TextboxState.Default: return Color.Black; case TextboxState.Error: return Color.Red; }
Thus, basically I define the real, not just the default default state of aka TextboxState.Default , adding the case default: I just want to do this to prevent future changes if new values ββare added to the enumeration.
According to the Swift book, this is not possible:
"If it is not practical to provide a switching case for all possible values, you can define a default blocking case for all values ββthat are not considered explicitly. In this case, the entire default keyword should always be displayed last ."
Is it clear in this paragraph that I assume that my template above is not Swift or am I missing something? Is there any other way to archive something like the above code?
enums swift
Mulli
source share