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
4242val res0 : Int = 0
4343```
4444
45- The companion object of an enum also defines two utility methods.
45+ The companion object of an enum also defines three utility methods.
4646The ` valueOf ` method obtains an enum value
4747by 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.
4950
5051``` scala
5152scala> Color .valueOf(" Blue" )
5253val res0 : Color = Blue
5354scala> Color .values
5455val res1 : Array [Color ] = Array (Red , Green , Blue )
56+ scala> Color .fromOrdinal(0 )
57+ val res2 : Color = Red
5558```
5659
5760### User-defined members of enums
You can’t perform that action at this time.
0 commit comments