|
I wrote the code like this:
But I'm not sure that it's okay to return the value, and then throw errors.. Could you please give me an advice? By the way, how can I post my code which is able to drag and copy - like other posts? |
|
Your function is perfectly fine.
Put three backticks |
|
@roosterboy Thank you! I changed my post as you told. Also, thank you for telling me that the code is fine - though I don't fully understand why it works well.. It makes me feel like there should be an error. Maybe I'm not confident about myself. |
|
Hey, we're on the same day! I'll share my code here just to reduce clutter and I seriously know no one who cares about this. I did two of these because I was really struggling with returns and errors and ended up doing extra research on them. I felt like I needed and still need practice. I did this first using a command called guard that we hadn't learned yet, but it really made more sense to me. And I didn't know how to do the square root of numbers so I had to look up and research sqrt theory and found the easy one about subtracting consecutive numbers, and figured I could try to do that. I hadn't read any of the hints yet so I guess I was building something to take any number and then limited it to 10k per instructions.
Anyways, I kind of felt like that was cheating given all the extra research I did and looked at the hints to give me more direction based on what we learned, and I came up with this.
Anyways. I'm super happy with this one b/c I feel like it was more true to the assignment based on the material. I spent a day on this problem, which is probably way too long, but I am not yet a programmer and this really is the very beginning of my journey. I love the challenge and the way of thinking involved. I kind of wanted to try a different one but I need to move on. Thanks for looking at my code. |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure and A/B test your entire paywall UI without any code changes or app updates.
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.