Skip to content

Lesson18, change for clarity #1325

@Xesy-poon

Description

@Xesy-poon

within lesson 18, there is a point when we talk about "unwrapping" the for loop with this example code

func run():
    var array = [0, 1, 2]
    var element

    element = array[0]
    print(element)

    element = array[1]
    print(element)

    element = array[2]
    print(element)

Now, i know the purpose of this lesson isn't teaching how to call on an array like this, but I find this block of code is confusing because it makes it look like, if you had an array of [3, 4, 5] you would write the code like this:

func run():
    var array = [3, 4, 5]
    var element

    element = array[3]
    print(element)

    element = array[4]
    print(element)

    element = array[5]
    print(element)

and obviously, this would give you an error since the array doesn't actually have any data in the #3 cell. but to someone who doesn't know just enough about coding to know the difference, this could cause confusion for them in the future.

I would recommend making the data in the array different from the address of the array, and with a little explanation as to what calling array[0] means

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentIssues with the lessons, practices, including their code examples

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions