|
In Paul's example of squaring numbers:
is it better or common practice to do the unwrapping in the function definition like this? why or why not?
|
|
If you allow a |
|
Thanks for the response - while I agree that the return may not be the right one, that is not the question - you can return however you want by changing the code in the 'else' block - so I still don't have my answer - |
|
@mplsrich retorts:
@rooster has answered 100s of questions in these forums. His answers are awesome and address the issue. Some folks give you the direct answer. But this is not ChatGPT. This is a learning site. I can see the correct answer in @rooster's response. This is something for you to think about and learn. If you have a box in your kitchen labeled "Sausage Maker", perhaps you're expected to only add meat parts and spices into the box and it will produce nice sausage. Why even try to add fruit? You're not going to get a smoothie. The box will just fail, and you'll damage your sausage maker. If you have a function in your code named The compiler will catch incorrect data ( |
|
To answer your second question:
A better concept is to use the For a sneek peek see -> Guarding the Gates Keep coding |
|
|
|
This is the kind of thing where you should always check that you have a valid value before calling the function.
|
|
I would not being doing a |
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 February 9th.
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.