Open
Description
In the "5. Extract duplicated code" task, submitting this solution fails:
...
fun wordCount(fileName: String): Int {
val file = checkFile(fileName)
var wordCount = 0
file.forEachLine { line ->
wordCount += line.split("\\s+".toRegex()).count()
}
return wordCount
}
private fun checkFile(fileName: String): File {
val file = File(fileName)
if (!file.exists() || !file.isFile) {
throw FileNotFoundException()
}
return file
}
fun copyFile(srcName: String, destName: String) {
val file = checkFile(srcName)
val to = File(destName)
file.copyTo(to)
}
While the err message states: Please, extract the code that checks if the file exists and is valid.
I think this solution should also be accepted, or, if you reject the suggestion then, at least, that sentence should be shown in the task description.
Metadata
Metadata
Assignees
Labels
No labels