How to get Enumeration Value's Enumeration definition?

I don't think you can unfortunately TestEnum. One is really just an instance of the class Enumeration#Value In fact, it's lots worse than just this - your enumeration values are all erased by type to the same thing: object Weekday extends Enumeration { val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value } def foo(w: Weekday. Value) def foo(e: TestEnum.

Value) //won't compile as they erase to same type As the instances of your enumeration are just instances of Enumeration#Value their declaring class is just scala. Enumeration It's frustrating but it seems like these scala enums are worse than useless; if you pass them through serialization (at least in 2.7.7), then you can't do equality checks either!

I don't think you can unfortunately. TestEnum. One is really just an instance of the class Enumeration#Value.In fact, it's lots worse than just this - your enumeration values are all erased by type to the same thing: object Weekday extends Enumeration { val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value } def foo(w: Weekday.

Value) def foo(e: TestEnum. Value) //won't compile as they erase to same type As the instances of your enumeration are just instances of Enumeration#Value, their declaring class is just scala.Enumeration.It's frustrating but it seems like these scala enums are worse than useless; if you pass them through serialization (at least in 2.7.7), then you can't do equality checks either!

Indeed,the scala default enum is awful,but it near to java enum,you can save your writing for simple enums :) – Ford Guo Jan 21 '10 at 4:21.

I am going to post a link to the Enum type that I wrote due to the limitations you mentioned. I don't use the built in enumeration type as I find it very limiting. Though it doesn't have the feature you would like (get the Enumeration from an Element), it would be pretty trivial to add it.

Feel free to use it in any way if you find it helpful. (source & test / example): gist.github.com/282446 BTW If you like and want help adding the container to the EnumElement let me know.

Like scala enum, – Ford Guo Jan 21 '10 at 4:19 not that I can think of this has a lot more power than the scala enumeration though, so it's a trade-off. The scala enum doesn't have a to string on its elements (unless you say Mon("Mon") ...), which is a common use case. – King Cub Jan 21 '10 at 15:45.

In my opinion there is a simple solution for not dealing with Scala Enumerations: use Java enum-s instead. Scala has supported cross-compiling for a while now and it's easy to just add a Java enum in your Scala source folder.

Sound good,I will make the choice,Thanks Erkki – Ford Guo Jan 22 '10 at 10:26.

Eric Abrahamson, a professor at Columbia Business School who specializes in leadership and organizational problem solving, has looked closely at ways employees manage to get paid to do nothing. He doesn't advocate following their example, but he says that understanding it can help managers address office inequities and make their teams more productive. Here are 10 tactics he's identified for avoiding working at work.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions