Enumeration withName

136 views
Skip to first unread message

Kornel Kiełczewski

unread,
Dec 31, 2014, 3:21:57 AM12/31/14
to scala-i...@googlegroups.com
Hi,
 it's a small detail yet might be useful. I find it annoying that a failed Enumeration#withName call tells me nothing about the argument supplied. What about a small change: 

   ...
   final def withName(s: String): Value = values.find(_.toString == s).getOrElse(
      throw new IllegalArgumentException(s"No value found for $s")
   ...

 If you think it makes sense, should I open an issue in the issue tracker and create a pull request from a new branch (as described in CONTRIBUTING.md)?


Cheers,
 Kornel

Som Snytt

unread,
Dec 31, 2014, 4:32:01 AM12/31/14
to scala-internals
I hope you open an issue.

I wouldn't quibble over which exception is thrown.

--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kornel Kiełczewski

unread,
Dec 31, 2014, 9:49:51 AM12/31/14
to scala-i...@googlegroups.com
Done, the PR  is here: https://github.com/scala/scala/pull/4228


Regards,
 Kornel

Kornel Kiełczewski

unread,
Jan 2, 2015, 7:02:25 AM1/2/15
to scala-i...@googlegroups.com
Ok, fixed the jira - https://issues.scala-lang.org/browse/SI-9067.


All the best in the coming year :)

Chris Howitt

unread,
Sep 4, 2015, 5:10:26 AM9/4/15
to scala-internals
Shouldn't withName return an Option[Value]?   Doesn't seem very 'Scala' to throw an exception rather than ask the client to deal with Option. c.f. Map.get 
Reply all
Reply to author
Forward
0 new messages