Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interesting exception to overloading enum rule from Sierra Bates book

 
nico dotti
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all. On page 65 of Bates and Sierra book there is an example enum where the getLidCode method is overloaded. There's a comment that says that <-- the semicolon is REQUIRED...
I just coded something similar that seems to work without the ';'. Granted I put the overloaded enum type first (their's has it last), but I didn't put a semicolon and it worked just fine. Here's the code:



Any comments or explanations?
[ November 14, 2007: Message edited by: nico dotti ]
 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A semi colon is required to end enum Constant declarations when you have an enum body(i.e variables, methods, Constructors), Not when you have a Constant specific class body.

And you still have to provide it in you example:
SMALL(8,"Live a little why don't you!"); <-
 
nico dotti
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ahmed...that makes sense to me. However, I didn't quite understand you're last comment - were you basically pointing out that my example itself confirms what you're saying given the ';' at the end?
 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, in your example you have an enum body, hence the semi colon is required.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic