Consider the code above and realize that any enumerated value not specifically processed by a case statement is instead processed by the default statement.
研究以上代码可以看出,任何没有被case语句处理的枚举值都会被default语句处理。
This is a great use-case for a Map, in which each key of the Map is one of these enumerated values, and each value is the error message for that key. Listing 10 illustrates how this works.
这是映射(map)的一个绝好用例,在这里,每个映射(map)的键都是一个枚举值,而每个值都是键的错误信息。
We can see that our Breed enumerated type contains several variables of type Value, as in the following example.
你可以看到我们的Breed 枚举类型包含了几种Value 类型的值,像下面的例子所展示的。
应用推荐