I Java I can write this:
Matcher m;
while ((m = pattern.matcher(string)).matches()) {...}
How would I do this in Scala? This doesn't work :
var m: Matcher = null
while ((m = pattern.matcher(s)).matches()) {}
Assignments return Unit
in Scala, but it's ok to use code blocks like this:
while ({
val m = pattern.matcher(s)
m.matches
}) { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With