Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Won't Fix
-
1.5.6
-
None
-
None
Description
The following code can not be executed and a exeception was throwed when I tried to execute it:
groovy.lang.MissingMethodException: No signature of method: Script3.listPaths() is applicable for argument types: (java.io.File) values:
def listPaths = { File location -> def result = [] result << location.canonicalPath if (location.isDirectory()) { File[] files = location.listFiles() for (f in files) { result.addAll(listPaths(f)) } } return result } listPaths(new File('d:/temp'))
Luckily, we can use the following method which is same with the above closure in terms of function.
Could you tell me why the implementation with closure failed? Thanks!
def listPaths(File location) { def result = [] result << location.canonicalPath if (location.isDirectory()) { File[] files = location.listFiles() for (f in files) { result.addAll(listPaths(f)) } } return result } listPaths(new File('d:/temp'))