File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
docs/docs/reference/enums Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -42,16 +42,19 @@ scala> red.ordinal
42
42
val res0 : Int = 0
43
43
```
44
44
45
- The companion object of an enum also defines two utility methods.
45
+ The companion object of an enum also defines three utility methods.
46
46
The ` valueOf ` method obtains an enum value
47
47
by its name. The ` values ` method returns all enum values
48
- defined in an enumeration in an ` Array ` .
48
+ defined in an enumeration in an ` Array ` . The ` fromOrdinal `
49
+ method obtains an enum value from its ordinal (Int) value.
49
50
50
51
``` scala
51
52
scala> Color .valueOf(" Blue" )
52
53
val res0 : Color = Blue
53
54
scala> Color .values
54
55
val res1 : Array [Color ] = Array (Red , Green , Blue )
56
+ scala> Color .fromOrdinal(0 )
57
+ val res2 : Color = Red
55
58
```
56
59
57
60
### User-defined members of enums
You can’t perform that action at this time.
0 commit comments