valueOf deprecated; use withName instead

View: New views
1 Messages — Rating Filter:   Alert me  

valueOf deprecated; use withName instead

by Daniel Sobral :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So, valueOf has been deprecated, and one should use withName instead. Are we sure we are going forward?
 
scala> Dimension.valueOf("xxx")
<console>:9: warning: method valueOf in class Enumeration is deprecated: use withName instead
       Dimension.valueOf("xxx")
                 ^
res4: Option[Dimension.Value] = None
 
scala> Dimension.withName("xxx")
java.util.NoSuchElementException: None.get
        at scala.None$.get(Option.scala:177)
        at scala.None$.get(Option.scala:175)
        at scala.Enumeration.withName(Enumeration.scala:122)
        at .<init>(<console>:9)
        at .<clinit>(<console>)
        at RequestResult$.<init>(<console>:4)
        at RequestResult$.<clinit>(<console>)
        at RequestResult$result(<console>)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(N...
 
Never mind about the method name. The change from Option to an Exception is a terrible idea.

--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.