I am not good at painless either but have done a little.
First question: are you trying to use in an ingest pipeline ..what is the context?
- Definitely look at the docs here
The example in detail here that shows the proper way to define a function you are missing the defs
def addwords(def id, def words) {
3 you can use the Dev Tools - Painless debugger to work on syntax
def addwords(def id, def words) {
String[] fiiled2 = new String[] {'foo','bar','word1'};
if (id.equals(1)) {
return fiiled2[id];
}
return words[id];
}
String[] words_var1 = new String[] {'word1','word1','word1'};
addwords(1, words_var1);
So you can use the debugger you will just need to substitute the context variables with some locals to debug ... then switch back to _ctx.
