We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9f83b52 + 499e716 commit 21aee87Copy full SHA for 21aee87
docs/docs/reference/enums/enums.md
@@ -42,16 +42,19 @@ scala> red.ordinal
42
val res0: Int = 0
43
```
44
45
-The companion object of an enum also defines two utility methods.
+The companion object of an enum also defines three utility methods.
46
The `valueOf` method obtains an enum value
47
by its name. The `values` method returns all enum values
48
-defined in an enumeration in an `Array`.
+defined in an enumeration in an `Array`. The `fromOrdinal`
49
+method obtains an enum value from its ordinal (Int) value.
50
51
```scala
52
scala> Color.valueOf("Blue")
53
val res0: Color = Blue
54
scala> Color.values
55
val res1: Array[Color] = Array(Red, Green, Blue)
56
+scala> Color.fromOrdinal(0)
57
+val res2: Color = Red
58
59
60
### User-defined members of enums
0 commit comments