The Artima Developer Community
Sponsored Link

Programming in Scala Forum
Enumeration bug?

1 reply on 1 page. Most recent reply: Feb 12, 2011 8:21 PM by Otfried Cheong

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Otfried Cheong

Posts: 5
Nickname: otfried
Registered: Dec, 2010

Enumeration bug? Posted: Feb 11, 2011 10:26 PM
Reply to this message Reply
Advertisement

Welcome to Scala version 2.8.1.final (Java HotSpot(TM) Client VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

scala> object Color extends Enumeration {
| val Red, Green, Orange, Black = Value
| }
defined module Color

scala> for (col <- Color.values)
| println(col)
Red
Green
Orange
Black

scala> import Color._
import Color._

scala> for (col <- Color.values)
| println(col)
Red
Green
Orange
Black
Value


What is the Value doing there in the last line?

The problem can be avoided by replacing the import statement by

import Color.{Value=>_,_}

But this is awkward.

Cheers,
Otfried


Otfried Cheong

Posts: 5
Nickname: otfried
Registered: Dec, 2010

Re: Enumeration bug? Posted: Feb 12, 2011 8:21 PM
Reply to this message Reply
Replying to myself: It's a known bug, to be fixed in 2.9.0

https://lampsvn.epfl.ch/trac/scala/ticket/3687

Sorry, I should have checked the bug tracker first.

Flat View: This topic has 1 reply on 1 page
Topic: 2nd Edition - pg 667 - XML Pattern Matching Previous Topic   Next Topic Topic: When will physical copies ship?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use