Function
Last updated
Last updated
Function task executes JavaScript or Groovy script.
Attribute | Description |
---|---|
Attribute | Description |
---|---|
JDK provides JavaScript engine named Nashorn and this engine is removed since JDK 15. After JDK 15, gravalVM is used as an alternative of Nashorn engine.
And there is a slight change on JavaScript function execution after JDK 8.
This is the definition of Groovy (from Wikipedia)
The example script of Groovy is like this.
Sccript | Result |
---|---|
Sccript | Result |
---|---|
Sccript | Result |
---|---|
8
Named function can be executed.
The last function is executed if unnamed function does not exist.
Unnamed function has the highest priority.
9+
Named function cannot be executed.
Unnamed function is executed.
function hello () {
return "Hello";
}
Hello
function () {
return "Hello";
}
Hello
function add(a,b) {
return a + b;
}
function a () {
return add(1,2);
}
3.0
function a(a, b) {
return a + b;
}
function () {
return a(1,2);
}
function b() {
return "Hello";
}
3.0
function hello () {
return "Hello";
}
Error
function () {
return "Hello";
}
Hello
function add(a,b) {
return a + b;
}
function () {
return add(1,2);
}
3
Apache Groovy is a Java-syntax-compatible object-oriented programming language for the Java platform. It is both a static and dynamic language with features similar to those of Python, Ruby, and Smalltalk. It can be used as both a programming language and a scripting language for the Java Platform, is compiled to Java virtual machine (JVM) bytecode, and interoperates seamlessly with other Java code and libraries.
Script Type
JavaScript or Groovy
Function
Script contents
ResultValue
The return value from the script, if exists.
UseDataStructure
Map data structure to the return value. This is used at mapping component.
DataStructureId
Data structure id for future mapping.