val LIST = scala.collection.mutable.MutableList[String]()
val filterF = new Function[Path, Boolean] {
def apply(x: Path): Boolean = {
println("looking into " + x)
val flag = if (x.toString.split("/").last.split("_").last.toLong < System.currentTimeMillis) {
println("considered " + x)
LIST += x.toString
return true
} else {
println("NOT considered " + x)
return false
}
return flag
}
}
I am trying to update the external variable LIST
inside the function filterF
. But the problem is that after the println("looking into "+x)
line the rest of the code is unreachable.
val flag = if (x.toString.split("/").last.split("_").last.toLong < System.currentTimeMillis) {
println("considered " + x)
LIST += x.toString
return true
} else {
println("NOT considered " + x)
return false
}
return flag
I can't understand why this code is unreachable. Is there some character in the code that is actually reason for this?