|
I'm looking for some pointers on coding more efficiently.
|
|
Your code tells me you come from a background where you learned procedural programming.
You ask:
I would ask you to think about rock objects, and paper objects and scissor objects. Simplify your code by thinking about and using objects! Now ask yourself.
You don't have to noodle very long to realize your choices are rock, paper, and scissors. And
Now that you have a way to assign a Choice to your user, how do you get the iPhone to make a choice? What FUNCTION might you need to get a RANDOM choice? You can add functions to enumerations.
You have more work to do!
|
|
Note: @rooster has a complete rock, paper, scissors enum in the forum. But you asked for help and ideas. Please try to fill out the functions on your own before taking a peep at his code. |
|
Ah, I never knew about enum's RawValue identity. That helps things. However, I don't understand the following:
If |
|
Hover your mouse over the Click the name. It should tell you what kind of object you're over. It will tell you that One of the things that
In your application, you have a fully featured object with the name of You're correct! All you have to do is give that shiny new, fully featured Choice object a name! I suggested |
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.