Programming in Swift: Functions & Types

Jan 4 2022 · Swift 5.5, iOS 15, Xcode 13

Part 1: Functions

04. Overloading

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 03. Challenge: Functions Next episode: 05. Advanced Parameters

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 04. Overloading

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.

In the previous episode, we reviewed several functions that shared the same name. When you create multiple functions with the same name, it’s called “Overloading”.

func getPassStatus(for grade: Int) -> Bool {
  grade >= passingGrade
}
func getPassStatus(for grade: Int, lowestPass: Int ) -> Bool {
  grade >= lowestPass
}
getPassStatus(for: ozmaGrade, lowestPass: 88)
getPassStatus(for: jessyGrade)
func getPassStatus(for grade: Int, lowestPass: Int = passingGrade ) -> Bool {
  grade >= lowestPass
}
func getPassStatus
  
}
func getPassStatus(for grades: [Int]) -> Bool {
  
}
func getPassStatus(for grades: [Int]) -> Bool {
  var totalGrade = 0
  for grade in grades {
    totalGrade += grade
  }
}
  let averageGrade = totalGrade / grades.count
}
  return averageGrade >= passingGrade
}
getPassStatus(for: ozmaAllGrades)
stride(from: 10, to: 0, by: -2)
for i in stride(from: 10, to: 0, by: -2) {
  print(i)
}
for i in stride(from: 10, through: 0, by: -2) {
  print(i)
}
func getValue() -> Int {
  return 13
}
func getValue() -> String {
  "meow"
}
let value = getValue()
let intValue: Int = getValue()