goncalossilva
10/17/2016, 5:57 PMfor (let i = 1; i <= string.length && i < MAX_LENGTH; i++)
My first attempt in Kotlin was:
for (i in 1..Math.max(string.length, maxLength))
However, this is wrong. It’s wrong because string
is reassigned inside the loop (substring
), and the range won’t be evaluated again.