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 3fafbc2 + ade2ce8 commit 61caba4Copy full SHA for 61caba4
src/library/scala/Enumeration.scala
@@ -121,7 +121,8 @@ abstract class Enumeration (initial: Int) extends Serializable {
121
* @throws NoSuchElementException if no `Value` with a matching
122
* name is in this `Enumeration`
123
*/
124
- final def withName(s: String): Value = values.find(_.toString == s).get
+ final def withName(s: String): Value = values.find(_.toString == s).getOrElse(
125
+ throw new NoSuchElementException(s"No value found for '$s'"))
126
127
/** Creates a fresh value, part of this enumeration. */
128
protected final def Value: Value = Value(nextId)
0 commit comments