In this code I want to increment index
to put it to each yield
ing result.
var index=0
for(str <- splitToStrings(text) ) yield {
if (index != 0) index += 1 // but index is equal to `0` all the time
new Word(str, UNKNOWN_FORM, index )
}
Why I can not change index
? And what the best way to implement this logic then, trying to be concise?