Just started recently and found this category, so I’m going to document here.
SO I just completed the Module 2, Lesson 2 challenge, where you have to draw cards from a randomly created deck… failed miserably LOL
I was super confident going in and thought i had it, but my code was littered with errors. It seemed like most of the errors came from trying to use the wrong kinds of variables in the wrong places so they were out of scope or ‘unwrapped’, not sure what that means.
I finally took Chris’ code and slowly picked it apart to get mine to work, but i have a million questions… gonna start researching the answers:
What exactly is a struct used for? (In this case it seems like just an array would work)
Where does it go? (Always outside of body view?)
Where do variable declarations go? (Why can i access some outside of body, others no?)
Why use @status? (I thought I knew, but the DECK status var in particular confuses me here)
Why use “Public vars”? (I thought i needed these to be accessible outside of a struct, etc, guess not?)
Why are underscores after an opening ( when declaring a function? (I can’t recall, gotta dig back again)
Why doesn’t my rand element version work (“wrapped/unwrapped errors”)?
I’ll see what I find and report back