Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7751289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:30:34+00:00 2026-06-01T11:30:34+00:00

I have the following code in Groovy 1.8.5 and to me it looks valid.

  • 0

I have the following code in Groovy 1.8.5 and to me it looks valid. Why does this give an error?

public enum Test
{
    ONE("meep"), TWO("jeep"), THREE("sheep");

    Test(String n)
    {
        this.n = n;
    }

    @Delegate String n;
}

println Test.ONE[1]
println Test.TWO[0] 

Edit 1:
I have a number of enumerated objects, so I want to put them in an enum. Each value of the enum represents an instance of those objects so why not store them there? Now, groovy enables me to do, say Test.One.digits instead of Test.One.n.digitswhich is handier.

When i try to run it in eclipse i get Exception in thread "main" java.lang.NoClassDefFoundError which i interpret as the class not being compiled properly. I don’t have the compiler message at the time though… I’m working on it.

Edit 2:

I got the script to work here though… http://gppconsole.appspot.com/script/34001
So I guess case closed and the problem is not the code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:30:36+00:00Added an answer on June 1, 2026 at 11:30 am

    What error do you get?

    public enum Test
    {
        ONE(1), TWO(2), THREE(3);
    
        Test(Integer n)
        {
            this.n = n;
        }
    
        @Delegate Integer n;
    }
    
    println Test.ONE.n
    

    works in Groovy 1.8.6… Though I’m not sure that adding a @Delegate to an enum is a good thing to do (I need to think about it more)…

    What are you trying to achieve?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: InputStream reportFile = MyPage.this.getClass().getResourceAsStream(test.jrxml); HashMap<String, String> parameters = new
Hi i have the following Groovy code: package fp; abstract class Function { public
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have following code using hibernate to throw a custom exception on error and
I have the following code in groovy, and I need to control to loop
I have the following piece of code in ItemController.groovy def list = { params.max
I have the following Groovy code but it wont work: xml = new groovy.xml.MarkupBuilder()
I have the following Groovy code : def number = 246 as List def
I have run the following code in this page RsyntaxTextArea using Java and i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.