Programming in Swift: Functions & Types

Jan 4 2022 Swift 5.5, iOS 15, Xcode 13

Part 1: Functions

2. Review Functions

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode
See versions

See course reviews

See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 1. Introduction Next episode: 3. Challenge: Functions

Update Notes: This course was originally recorded in 2019. It has been reviewed and all content and materials updated as of October 2021.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

You’ve had a fair bit of experience writing functions already! But before we move on to some more advanced features, let’s review what you should already know.

❤️func❤️ 💛printMeow💛💚()💚 🧡{
  print("Meow!")
}🧡
func printMeow💛()💛 {
  print("Meow!")
}
printMeow()
func printPassStatus💛(grade: Int)💛 {
  print(grade >= passingGrade ? "You passed!" : "Glue != food.")
}
printPassStatus(grade: jessyGrade)
func printPassStatus(grade: Int, lowestPass: Int = passingGrade) {
  print(grade >= lowestPass ? "Good kitty!" : "Keep your paws off the table!")
}
printPassStatus(grade: jessyGrade)
printPassStatus(grade: ozmaGrade, lowestPass: 80)
printPassStatus(grade: jessyGrade)
printPassStatus(💛grade💛: ozmaGrade, 💛lowestPass💛: 80)
func printPassStatus(for grade: Int, lowestPass: Int = passingGrade) {
  print(grade >= lowestPass ? "You've earned a treat." : "🙃")
}
printPassStatus(for: ozmaGrade, lowestPass: 80)
func printHighestGrade(💛_ grade1: Int, _ grade2: Int💛) {
  print(grade1 >= grade2 ? grade1 : grade2)
}
printHighestGrade(jessyGrade, ozmaGrade)
func getPassStatus(for grade: Int, lowestPass: Int = passingGrade) 💛-> Bool💛 {
  return grade >= lowestPass
}
func getPassStatus(for grade: Int, lowestPass: Int = passingGrade) -> Bool {
  💛return grade >= lowestPass💛
}
let jessyPassStatus = getPassStatus(for: jessyGrade)
func getPassStatus2(for grade: Int, lowestPass: Int = passingGrade) -> Bool {
  💛grade >= lowestPass💛
}
let ozmaPassStatus = getPassStatus2(for: ozmaGrade, lowestPass: 80)