Programming in Swift: Fundamentals

Oct 19 2021 · Swift 5.5, iOS 15, Xcode 13

Part 5: Functions & Named Types

35. Introduction to Functions

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: 34. Introduction Next episode: 36. Functions & Return

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: 35. Introduction to Functions

Update Notes: The student materials have been reviewed and are updated as of October 2021.

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

Functions are a core part of many programming languages. Simply put, a function lets you define a reusable block of code that performs a task.

func
func printHello()
func printHello() {

}
func printHello() {
  print("Hello!")
}
printHello()
printHello()
printHello()
let chrisPassed = chrisGrade >= passingGrade
let samPassed = samGrade >= passingGrade
func printPassStatus
func printPassStatus() {

}
func printPassStatus(grade: Int) {...
grade * 2
  ❌  grade * 2
  print(grade >= passingGrade)
  print(grade >= passingGrade ? "You passed!" : "Keep studying.")
printPassStatus(grade: samGrade)
func printPassStatus(grade: Int😺, lowestPass: Int🛑) {...
  print(grade >= 😺lowestPass🛑 ? "You passed!" : "Keep studying.")
printPassStatus(for: samGrade😺, lowestPass: 80🛑)
func printPassStatus(grade: Int, lowestPass: Int 😺= passingGrade🛑) {...
printPassStatus(grade: chrisGrade)
func printHighestGrade(grade1: Int, grade2: Int) {
  print(grade1 >= grade2 ? grade1 : grade2)
}
printHighestGrade(grade1: chrisGrade, grade2: samGrade)
func printHighestGrade(😺_ grade1: Int, 😺_ grade2: Int) {
printHighestGrade(chrisGrade, samGrade)
func printPassStatus(😺for 🛑grade: Int, lowestPass: Int = passingGrade) {...
printPassStatus(😺for🛑: samGrade, lowestPass: 80)
printPassStatus(😺for🛑: chrisGrade)