Is it possible to use variable trimmed in the code below without declaring it as a val?

 for {
   file <- filesHere
   if file.getName.endsWith(".scala")
   line <- fileLines(file)
   trimmed = line.trim
   if trimmed.matches(pattern)  
} println(file +": "+ trimmed)
You can compute trim by binding the result to a variable trimmed using an equals sign (=). The bound variable is introduced and used just like a val, only with the val keyword left out.
Source: For expressions

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Scala quizzes
Sign Up Now
or Subscribe for future quizzes