Open jman904 opened 2 months ago
Thank you for the feedback. In general, we are well aware of limits of the app and the series, and to me, it could use a holistic content pass to flesh everything out or even a remake to unlock some technological limitations. I'd like to go through everything and flesh it out more. But we have to focus on our school curriculum.
I think your issue, while I agree it would be something worth introducing, is something beyond the scope of this lesson, whose goal is just introducing how to access elements in an array by index. The lesson could be modified to make this more explicit.
I thought we reused the inventory example after this lesson closer to what you suggest, with dictionaries, but I'll have to check again.
I also found it unclear how to complete this task. I believe my issue is because the inventory array shown in the code was empty, and it didn't make much sense to iterate over or index into an empty array. I thought I might have to populate the array with something, but I couldn't figure out how to make that make sense.
The starting code:
var inventory = []
func pick_items():
It turns out that this array is actually populated with items, so I tried approaching the problem the same way as @jman904 and ran into the same issues. I had to look at the suggested solution to figure out what I was supposed to do for this problem, and that it expected me to just hard-code inventory indexes of the items I wanted to use.
I think if the inventory was declared as var inventory = ["gems", "sword", "shield", ....]
, or something similar, it would be a bit more intuitive how you're supposed to solve the problem.
I have a programming background so my immediate thought was that loops and conditional checking was what the problem was looking for, especially since the lesson module discusses use of the size() method. Something to the effect of
I wrote this solution assuming the inventory array contained strings, as shown in the associated lesson module, and was surprised to find this was not the case; string matching failed, inventory wasn't really accessible, print functions (e.g., print(inventory.size()) didn't work like in the lesson) and my solution was just super broken. I then realized this was maybe over-engineered and tried the much simpler answer of human visual inspection of the inventory array image on the right and gave a hard-coded answer of use_item(inventory[x]) use_item(inventory[y]) and it worked. This feels wrong from a teaching perspective.
As a long time programmer and teacher, this lesson/practice really bothered me because it teaches a bad habit of hardcoding magic values specific to the example and doesn't teach anything about the dynamic nature of data which is a core concept. I feel like a much better lesson would include more boilerplate code to scan the inventory array, as described above in the pseudocode, and have the student flesh it out the rest of the way to make it functional in a more general purpose way (and teach better habits that more closely reflect real-world use cases). Maybe even just provide the full answer for finding the first sword and leave the student to copy it for finding the shield. Also maybe consider renaming the function pick_sword_and_shield() to be specific to the above pseudocode if making these changes.