Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics (retired) Control Flow While and Do-While Loop

What am I Doing wrong?

Thanks for taking your time into answering my questions guys I appreciate.

while_loops.swift
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
while numbers < todo.count {println(todo[numbers]) numbers++}

I thought that was the code.

1 Answer

Hey Ricardo,

What was the challenge and can you post all of your code along with what error you are getting as It's hard to see where the error is coming from depending on what you want to do.

Thanks, Alex

After looking at the challenge this is the working code:

let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
var timeOfLook = 0

while timeOfLook < numbers.count {
    println(numbers[timeOfLook])
    timeOfLook++
}

Looks like what you did wrong was having the conditions the wrong way around.

Your should have appended the .count to your numbers variable as it's the array.

Thanks, Alex.

I am supposed to do a loop.

I need the rest of your code.

You saying that there is more to this code???

No, what I was saying is that you hadn't posted all of your code. I had no idea what the variable 'todo' is

oh ok I see