Groovy web console

subscribe to the feed Subscribe
to this
site
testjo (via #groovywebconsole)
tweet this snippet Tweet
this
script

testjo

Published 4 months ago by jo with tags iab
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
//create and use method with return-value
def area (int i){
    if (i%2==0){
        return('area: '+Math.PI*i**2)
    }
    else{
        i=i+1
        return('radius was not an even number and has been increased by 1, area: '+Math.PI*i**2)
    }
}
println(area(5))