Programming in Kotlin - Part 32: Challenge: Lists | Ray Wenderlich

Practice using Lists on your own, through a hands-on challenge.

This is a companion discussion topic for the original entry at

Hey man, second challenge, given you want 3rd State out, not 3rd index (given index starts from 0) you are practically removing the fourth state. Also forEachIndexed might solve this cleaner, just personal opinion.

fun printStates(states: List<String>) {
    states.forEachIndexed { index, state ->
        if (index != 2) println(state)

You are correct. It should have been 2. forEachIndexed is a much easier solution. I used forEachIndexed in another video but wanted to keep it simple for this example.

1 Like

Hi @kevindmoore.
The project files have been provided is different with the lesson.
Please update the materials.

@kevindmoore Can you please help with this when you get a chance? Thank you - much appreciated! :]

Project files will be updated shortly

Exercise files should now be updated.