Groovy
Apache Groovy
Installation
Arch Linux
pacman -S groovy
SDKMAN!
sdk install groovy
Binary
# Download apache-groovy-binary-{version}.zip from https://groovy.apache.org
unzip apache-groovy-binary-{version}.zip
mv groovy-{version} /usr/local
export PATH=/usr/local/groovy-{version}:$PATH
Examples
Fibonacci Numbers
// Fibonacci Numbers by groovy
int fib(int n) {
if (n < 2) {
return n;
} else {
return fib(n - 2) + fib(n - 1);
}
}
int n = Integer.decode(args[0]);
println fib(n);
/*
example
run source code:
groovy fib.groovy 39
compile:
groovyc fib.groovy
run byte code:
groovy fib 39
*/