# Video Tutorial: Beginning Swift 2 Part 4: Functions

**URL:** <https://forums.kodeco.com/t/video-tutorial-beginning-swift-2-part-4-functions/6863>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 4, 2016, 12:13pm UTC](https://forums.kodeco.com/t/video-tutorial-beginning-swift-2-part-4-functions/6863 "2016-03-04T12:13:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregheo](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gregheo/32/71268_2.png) [@gregheo](https://forums.kodeco.com/u/gregheo)\
**Post date:** [March 4, 2016, 12:13pm UTC](https://forums.kodeco.com/t/video-tutorial-beginning-swift-2-part-4-functions/6863/1 "2016-03-04T12:13:51Z")

</div>

Learn how to use functions in Swift 2 to group your code together to into a reusable unit .

 
* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/3250-beginning-swift-2/lessons/5](https://www.raywenderlich.com/3250-beginning-swift-2/lessons/5)

---

<div class="post-metadata">

**Author:** ![ronm11](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ronm11/32/36706_2.png) [@ronm11](https://forums.kodeco.com/u/ronm11)\
**Post date:** [July 11, 2016, 5:26pm UTC](https://forums.kodeco.com/t/video-tutorial-beginning-swift-2-part-4-functions/6863/2 "2016-07-11T17:26:59Z")

</div>

After all these years of studying Objective C, Swift, and iOS, someone finally properly explains what appears to be a double use of certain variable names. I never could get the concept down until this video…external vs. internal uses of name-variables. This alone is worth the price of admission. Thank you. You are an awesome instructor.

---

<div class="post-metadata">

**Author:** ![gregheo](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gregheo/32/71268_2.png) [@gregheo](https://forums.kodeco.com/u/gregheo)\
**Post date:** [July 12, 2016, 4:23am UTC](https://forums.kodeco.com/t/video-tutorial-beginning-swift-2-part-4-functions/6863/3 "2016-07-12T04:23:16Z")

</div>

Thanks for the kind words, and I hope you enjoy the rest of the videos & the intermediate series too!

---

<div class="post-metadata">

**Author:** ![janice](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/janice/32/71291_2.png) [@janice](https://forums.kodeco.com/u/janice)\
**Post date:** [July 17, 2016, 11:32am UTC](https://forums.kodeco.com/t/video-tutorial-beginning-swift-2-part-4-functions/6863/4 "2016-07-17T11:32:32Z")

</div>

Questions:

**01** “I should be storing its return.” (7:40) Does this mean utilizing the return value?  
**02** Why create the constant restaurantTotal? Why not simply use totalBill?

---

<div class="post-metadata">

**Author:** ![yogiii](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/yogiii/32/83116_2.png) [@yogiii](https://forums.kodeco.com/u/yogiii)\
**Post date:** [August 2, 2016, 12:18pm UTC](https://forums.kodeco.com/t/video-tutorial-beginning-swift-2-part-4-functions/6863/5 "2016-08-02T12:18:09Z")

</div>

Hi. So I could clearly understand the meaning of spreading these functions let me know if I’m thinking correctly:

Function: tipPercentageForRating(rating: Int) - returns percentage amount but requires rating

Function: calculateTipOnTotal - returns tip amount (depending on percentage amount) but requires bill amount and percentage amount (which requires rating)

Function: showTipAdvice - does not return anything, but requires tip amount (which requires bill amount, percentage amount and rating). Don’t understand what is the purpose of the showTipAdvice and why it does not need to return any value?

---

<div class="post-metadata">

**Author:** ![yogiii](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/yogiii/32/83116_2.png) [@yogiii](https://forums.kodeco.com/u/yogiii)\
**Post date:** [August 2, 2016, 1:45pm UTC](https://forums.kodeco.com/t/video-tutorial-beginning-swift-2-part-4-functions/6863/6 "2016-08-02T13:45:14Z")

</div>

“Why create the constant restaurantTotal? Why not simply use totalBill?”

My thoughts exactly. Why creating a function showTipAdvice that does not return anything just to printout. A bit confusing.

---

<div class="post-metadata">

**Author:** ![edwards-shea](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/edwards-shea/32/81494_2.png) [@edwards-shea](https://forums.kodeco.com/u/edwards-shea)\
**Post date:** [August 3, 2016, 5:02pm UTC](https://forums.kodeco.com/t/video-tutorial-beginning-swift-2-part-4-functions/6863/7 "2016-08-03T17:02:09Z")

</div>

Just a small math point you are not calculating percentages but fractions
