|
Hello! I would appreciate some assistance in verifying whether my solution for checkpoint 6 is accurate. Your help is greatly appreciated. Thank you! Here's my code
I'd also like to ask if my usage of private(set) is correct. It's still quite unclear to me and honestly, I just guessed it. Any more information that would provide further clarity would be greatly appreciated. |
|
Look good. This can not be done (Error:
so to change The only thing is why do you need to return a
Whole code
|
|
I apologize if this might sound a bit stupid but why is it that we don't need to return a bool? I thought we have to return a bool so that it knows if we can shift our gears either up or down (Bool serves as the validation of the gear range). Am I misunderstanding things incorrectly here? Feel free to correct me as I really want to be able to grasp why. |
|
Well, for one thing, you return a
What are you doing with the Returning anything is not necessary. You can do it if you want, but then you should do something with that result or otherwise what's the point of returning anything at all? |
|
I see. So that means I only have to return something if I have to use that returned value somewhere? Otherwise, if I don't need whatever's being returned by our function, then I can completely remove any -> data type statments? |
|
A new hacker may be forgetting who's in charge when writing code!
You're in charge of the logic!Don't forget who's writing the code! You! You may have a business use case where you're telling your car, the Hacker900, that it needs to switch down one gear. But your use case says to switch down on demand. So you might code the following:
But your quality control team might wonder, did we really shift down? Can we verify our request was executed? In this business case, you might write the following code:
Whether you include a return bool or not is up to you and your business case. You're the programmer! Keep coding! |
|
As
It would keep add one to In your first code I could not see you used |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's all new Paywall Editor allow you to remotely configure your paywall view 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.