Learn how to use structs in Swift 2 to combine data and functions.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3250-beginning-swift-2/lessons/7
Learn how to use structs in Swift 2 to combine data and functions.
Why do you return totalBill inside of the guard statement? If it is outside the condition of the guard, shouldn’t you return 0? Currently you are returning the totalBill which makes the calculateTip() function return the totalBill amount as the tip.
Unless I’m not thinking about this right…A waiter at a restaurant with a rating of 6 would get a really good tip
Hey @patrickpowers10, you’re right — someone reported this in another video and I fixed the playgrounds there but missed this group. I’ll get those updated.
I think the original version of the method calculated the total rather than just the tip, and the code got left there after the refactor to calculateTip()
. Thanks for bringing this up!
—Greg
I do agree with your statement @patrickpowers10