I’m new to Groovy. I want to achieve this:
def a = { assert 1 == 1 }
def method(def a)
{
println a
}
method(a)
The println now prints ConsoleScript1$_run_closure1@72e9108f. But I wish it would print assert 1 == 1. Is that possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Using the answer I linked to as a duplicate of this, if you save:
to a file
test.groovythen do:You get the output:
Which is as close as you’re going to get I think… Without using the positional data in the
codevariable (which is a Groovy Statement class) to get the line/col numbers and parse the file as text to extract it…