Script runner

Yevgeniy Klyagin March 3, 2015

Hi, all!

I'm new in Groovy and Script runner. I have the list of strings and I can't iterate them with cycles "for", "foreach" etc.:

data = ["1", "2", "3", "4", "5"]
for (e in data) {
println e
}

And as result I get:  no return value

Can you assist me in this issue?

Thanks!

 

2 answers

2 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 3, 2015

I think the issue is that println is going to catalina.out, whereas Evgeniy is expecting it to be returned in the UI. The script console will return the value of the last statement executed, which for println, is nothing.

If you tail your catalina.out you should see it there, but that's not easy to debug like that.

1 vote
MichałS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 3, 2015

Hi,

Just use the syntax like this:

data.each() {
	println "${it}"
}

You shoud read the docs about looping in groovy as well smile (http://groovy.codehaus.org/Looping).

You could use the simple Java syntax as well, but then it wouldn't be that fancy smile

Yevgeniy Klyagin March 5, 2015

Thank you. It's works)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events