Scala

Scala

Made by DeepSource

Use 'until n' instead of 'to n - 1' in loops SC-R1016

Anti-pattern
Minor

for (i <- 0 to n - 1) is the common way to count from 0 till n. However, a more readable and appropriate way might be to adopt the 'until' keyword.

Bad Practice

for (i <- 0 to n - 1) {
  println(i)
}

Recommended

for (i <- 0 until n) {
  println(i)
}