Norm
(Norman Walsh)
1
This is presumably a simple question, but all of my attempts to search for the answer are stymied by the commonality of the search terms.
The filter
closure on the Gradle Copy
task is defined, in part, like this:
The Closure will be called with each line (stripped of line endings) and should return a String to replace the line or null
to remove the line.
But if you actually do that in Kotlin:
filter { line ->
if (line.contains("thing i want to suppress")) {
null
} else {
line
}
Kotlin complains:
w: .../build.gradle.kts: Type mismatch: inferred type is Nothing? but String was expected
I can see why, but can I reformulate the filter closure so that Kotlin doesn’t make me feel bad?
Vampire
(Björn Kautler)
2
Yeah, this is a known problem.
Some related reports that also have some work-arounds for similar cases you could maybe adapt:
This should hopefully fix it properly “some time”:
Norm
(Norman Walsh)
3
Ah. Thank you. I’ll just ignore the warning and hope it goes away
1 Like