I have a piece of code like this
def filter(t: String) : Boolean = {
var found = false;
for(s <- listofStrings) {
if ( t.contains(s)) { found = true}
}
found
}
The compiler gives a warning that its not good practise to use a mutable variable. How do I avoid this ?
Disclaimer: I used a variant of this code in an assignment and the submission is done. I would like to know what the right thing to do is