Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in collections-loops implementation #1

Open
barkantoprak opened this issue Aug 4, 2021 · 0 comments
Open

Bug in collections-loops implementation #1

barkantoprak opened this issue Aug 4, 2021 · 0 comments

Comments

@barkantoprak
Copy link

Hi, there is an error in collections-loops implementation.

At while loop, the incrementation of variable "i" must be outside of while loop or should be implemented differently.

Because, if the condition in while loop is not met, the "i" is not incremented and causes it to work incorrectly.

I think this is the correct solution:

var i = 0

while (i < randoms.size) {
  if (randoms[i] <= 10) { //it is mentioned less than or equal to 10 in challenge
    println(randoms[i])
  }
  i++
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant