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 7518421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:44:53+00:00 2026-05-30T01:44:53+00:00

I am trying to dynamically evaluate a result of another function during a class

  • 0

I am trying to dynamically evaluate a result of another function during a class method call. However, having and issue with the scope of the Eval.

class A {
    private String a
    public A() {
        a = 5
    }

    public whatIsA() {
        return a
    }


    public func() {
        return "\\${whatIsA()}"
    }

    public test() {
        return Eval.me("\"\${func()}\"")
    }
}
def a = new A()
a.test()



Exception thrown: groovy.lang.MissingMethodException: No signature of method: Script1.func() is applicable for argument types: () values: {}

groovy.lang.MissingMethodException: No signature of method: Script1.func() is applicable for argument types: () values: {}
    at Script1.run(Script1.groovy:1)
    at A.test(Script7:17)
    at Script7.run(Script7:22)

How can I pass the scope of the A class instance into the Eval script?

  • 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-05-30T01:44:54+00:00Added an answer on May 30, 2026 at 1:44 am

    Try this?

    class A {
        private String a
        public A() {
            a = 5
        }
    
        public whatIsA() {
            return a
        }
    
        public func() {
            return "${whatIsA()} + 5"
        }
    
        public test() {
            return Eval.me(func())
        }
    }
    def a = new A()
    a.test()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to dynamically define functions that call through to another function that takes
I'm trying to evaluate an XPath varable I'm building dynamically based on the position
I am trying to dynamically filter search results. Every result has tags associated with
I'm trying to dynamically create a connection string during compile time: private static string
I'm trying to dynamically create buttons at runtime with PyQT4.7 However, this being my
I'm trying to dynamically and a link to an image, however I cannot correctly
Is it possible to dynamically build a property or function call? I have a
I'm trying to dynamically create this function: svg.path($('#shape23'), path.move(333,410) .smoothC(333,410,333,410) .smoothC(217.5,415.75,217.5,415.75) .smoothC(333,500,333,500) .close(), {fill:
I am trying to dynamically load a user control in an asp.web site. However
I'm trying to dynamically bind mysql_stmt parameters and get the result in an associative

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.