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
within lesson 18, there is a point when we talk about "unwrapping" the for loop with this example code
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:
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