estevanfick
06/29/2023, 12:27 PMstatic copyAndRenameChildFiles(File sourceDir, Closure<String> filenameTransform)
and I'm trying to call from a kotlin script, I tried to use `closureOf`like this:
val copyDir = FileUtils.copyAndRenameChildFiles(svgSrcDir, closureOf<String> { this.replace("-", "_") })
but I'm getting the error:
Type mismatch: inferred type is Closure<Any?> but Closure<String!>! was expected
the original call on Groovy was:
File copyDir = FileUtils.copyAndRenameChildFiles(svgSrcDir, { String filename -> filename.replace("-", "_") })
Sam
06/29/2023, 12:34 PMClosure
is its return type, whereas the type parameter of closureOf
is the input type 😬. Try KotlinClosure1<String, String>({ this.replace("-", "_") })
, which lets you specify both type parameters.Sam
06/29/2023, 12:34 PMestevanfick
06/29/2023, 12:36 PMVampire
06/29/2023, 12:36 PMcopyAndRenameChildFiles
, use Transformer
instead of Closure
Vampire
06/29/2023, 12:36 PM