I’ve got the following groovy code:
dataFile.filterLine() {it =~ /(${searchStr1}|${searchStr2})/ }.each { it ->
println it
it.split { list ->
println "split line: ${list[0]}, ...."
}
}
The first println works great — lists all the matching lines. Then, the split causes an error, in fact on the second println. Obviously it doesn’t like the ${list[0]}. But, I’m not clear what is wrong with that.
Error is:
No signature of method: org.codehaus.groovy.runtime.DefaultGroovyMethods$4.getAt() is applicable for argument types: (java.lang.Integer) values: [0]
Possible solutions: getAt(java.lang.String), putAt(java.lang.String, java.lang.Object), wait(), grep(), getClass(), wait(long). Stacktrace follows:
Thanks
filterLinedoesn’t return what you think it does; it’s aWritable, containing all the matches from the input file.Here’s a minimal example: