Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Enum in Eclipse Scrapbook

Reply
Thread Tools

Enum in Eclipse Scrapbook

 
 
Lew
Guest
Posts: n/a
 
      02-27-2013
Robert Mark Bram wrote:
> markspace wrote:
>> No se hablo Eclipse Scapbook -- is that a plugin? Like some sort of
>> bean shell or copy-paste tool?

>
> No - it's in vanilla Eclipse, and it's pretty cool.
>
> This page gives some beginner's info on it: http://www.eclipsezone.com/eclipse/forums/t61137.html


Nowhere does it state that its purpose is to define complex classes. Its purpose is to execute expressions.

So define your classes where you're supposed to, in their own source files.

--
Lew
 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      02-28-2013
On 2/28/2013 4:02 AM, lipska the kat wrote:
> On 27/02/13 20:25, Lew wrote:
>> Robert Mark Bram wrote:
>>> markspace wrote:
>>>> No se hablo Eclipse Scapbook -- is that a plugin? Like some sort of
>>>> bean shell or copy-paste tool?
>>>
>>> No - it's in vanilla Eclipse, and it's pretty cool.
>>>
>>> This page gives some beginner's info on it:
>>> http://www.eclipsezone.com/eclipse/forums/t61137.html

>>
>> Nowhere does it state that its purpose is to define complex classes.
>> Its purpose is to execute expressions.
>>
>> So define your classes where you're supposed to, in their own source
>> files.

>
> Have you even tried this ?
>
> the scrap
>
> //
> enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};
>
> Month m = Month.JAN;
> //
>
> is not a 'complex class'
>
> Month m = Month.JAN;
>
> is an expression, yet it still fails.


The original example was also an expression.

But both the original example and your example
contains a nested type.

And apparently scrapbook does not support nested types.

So the solution is to move the nested types out as top
level types.

As Lew said. Assuming that we consider enum a class.

Arne


 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      02-28-2013
On Tue, 26 Feb 2013 21:52:10 -0800 (PST), Robert Mark Bram
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone
who said :

>A a = new A();
>
>When I try to execute this I get:
>
>The member enum Month can only be defined inside a top-level class or interface


you can't create enum constants on the fly. You must say
A a = A.MAR;
--
Roedy Green Canadian Mind Products http://mindprod.com
One thing I love about having a website, is that when I complain about
something, I only have to do it once. It saves me endless hours of
grumbling.
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      02-28-2013
On 2/28/2013 10:24 AM, lipska the kat wrote:
> On 28/02/13 13:28, Arne Vajh°j wrote:
>> On 2/28/2013 4:02 AM, lipska the kat wrote:
>>>On 27/02/13 20:25, Lew wrote:
>>>>Nowhere does it state that its purpose is to define complex

classes. Its purpose is to execute expressions.
>>>>
>>>>So define your classes where you're supposed to, in their own

source files.
>>>>
>>>
>>>enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};
>>>
>>>Month m = Month.JAN;
>>>
>>>is not a 'complex class'
>>>
>>>Month m = Month.JAN;
>>>
>>>is an expression, yet it still fails.

>>
>> The original example was also an expression.
>>
>> But both the original example and your example
>> contains a nested type.
>>
>>And apparently scrapbook does not support nested types.
>>
>>So the solution is to move the nested types out as top

level types.
>>
>>As Lew said. Assuming that we consider enum a class.

>
> It's not my example you buffoon, it's the OPs


No.

OP's example was:

class A {
enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
}
A a = new A();

So it is:

implicit class - nested enum

and:

implicit class - nested class - nested enum

OP's example gives 1 error.

Your example give 3 errors (where the first is the
one in OP's example).

So Lew's comment is absolutely correct - moving class A out
as a top level class in its own file will solve the problem.

For reasons unknown to me you posted a similar but not identical
example.

Lew's solution still applies though - just by moving the enum
Month out as top level.

So stop whining and express your admiration that Lew analyzed
the problem correctly.

Arne

 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      02-28-2013
On 2/28/2013 10:43 AM, Roedy Green wrote:
> On Tue, 26 Feb 2013 21:52:10 -0800 (PST), Robert Mark Bram
> <(E-Mail Removed)> wrote, quoted or indirectly quoted someone
> who said :
>>class A {
>> enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
>>}
>> A a = new A();
>>
>> When I try to execute this I get:
>>
>> The member enum Month can only be defined inside a top-level class or interface

>
> you can't create enum constants on the fly. You must say
> A a = A.MAR;


????

Have you read what you replied to?

Arne


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      02-28-2013
Arne Vajh°j wrote:
> ... Assuming that we consider enum a class.


It doesn't matter what you assume or consider, an enum is a class.

--
Lew
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      03-04-2013
On 2/28/2013 5:09 PM, Lew wrote:
> Arne Vajh°j wrote:
>> ... Assuming that we consider enum a class.

>
> It doesn't matter what you assume or consider, an enum is a class.


That is how JLS define it.

But some may consider class to be something with they class keyword.

Arne


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      03-04-2013
Arne Vajh°j wrote:
> Lew wrote:
>> Arne Vajh°j wrote:
>>> ... Assuming that we consider enum a class.

>>
>> It doesn't matter what you assume or consider, an enum is a class.

>
> That is how JLS define it.


Q.E.D.

> But some may consider class to be something with they class keyword.


Some would be wrong.

Things are what they are. If you consider them not to be, you are wrong.

Some need to educate themselves.

--
Lew

 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      03-07-2013
On 3/4/2013 2:36 PM, Lew wrote:
> Arne Vajh°j wrote:
>> Lew wrote:
>>> Arne Vajh°j wrote:
>>>> ... Assuming that we consider enum a class.
>>>
>>> It doesn't matter what you assume or consider, an enum is a class.

>>
>> That is how JLS define it.

>
> Q.E.D.
>
>> But some may consider class to be something with they class keyword.

>
> Some would be wrong.
>
> Things are what they are. If you consider them not to be, you are wrong.
>
> Some need to educate themselves.


I am a bit less dogmatic about such things.

I don't have a problem with people referring to actual Java syntax
instead of the explanation in English in JLS.

Arne


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      03-07-2013
Arne Vajh°j wrote:
> Lew wrote:
>> Arne Vajh°j wrote:
>>> Lew wrote:
>>>> Arne Vajh°j wrote:
>>>>> ... Assuming that we consider enum a class.

>
>>>> It doesn't matter what you assume or consider, an enum is a class.

>
>>> That is how JLS define it.

>
>> Q.E.D.

>
>>> But some may consider class to be something with they class keyword.

>
> > Some would be wrong.


Of course, I'm wrong in the Enum does, indeed, use the 'class' keyword.

public abstract class Enum<E extends Enum<E>>
"This is the common base class of all Java language enumeration types."

>> Things are what they are. If you consider them not to be, you are wrong.

>
>> Some need to educate themselves.

>
> I am a bit less dogmatic about such things.
>
> I don't have a problem with people referring to actual Java syntax
> instead of the explanation in English in JLS.


Then we agree, since the "actual Java syntax" is that it's a class.
http://docs.oracle.com/javase/7/docs...lang/Enum.html

And what you disingenuously call "the explanation in English in [the] JLS" is not an
explanation but a specification, an entirely different beast, that normatively *defines*
the terms.

--
Lew

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
enum: display elements of an enum specified at runtime Jerminia Java 3 10-07-2005 10:08 PM
enum within an enum - Java 6 06-13-2005 12:51 AM
Scrapbook type application TS Digital Photography 1 08-29-2004 11:23 AM
Including an enum within another enum, possible? mrhicks C Programming 2 06-10-2004 03:00 AM
How to enum an enum? Ernst Murnleitner C++ 5 11-13-2003 11:06 AM



Advertisments