Programming in Swift: Functions & Types

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

Part 4: Properties & Methods

34. Challenge: Methods

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: 33. Methods Next episode: 35. Computed Properties or Methods?

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: 34. Challenge: Methods

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.

It’s time for some practice with methods. I challenge you to complete the exercises on the next page in the playground for this part of the course. Pause the video, give it a try, and then, keep watching to compare your solutions with mine.

  mutating func curveGrades() {

  }
41 var grade…
46 var students
53 var classroom
guard let highestGrade = getHighestGrade() else {
      return
    }
students =
      students.map { student in
        return student
      }
75 let curveAmount = 100 - highestGrade
76 var student = student
77 student.grade += curveAmount
74 students.map { [curveAmount = 100 - highestGrade] student in
        var student = student
79 .sorted { $0.grade > $1.grade }
classroom.curveGrades()
84 classroom.students