Need help with School Database task: iterating over set + optionals

Hi all!

I got stucked with the task.
I need to write a method which iterates over Teachers and returns ones if conditions met.

Here is my code:

struct School {
  var name: String
  var teachers: [Teacher]

  func getTeacher(withID id: Int) -> [Teacher]? {
    for teacher in teachers {
 
      if teacher.id == id {
        return teacher
      } else {
        return nil
      }
    }
  }

I know I do something wrong, coz it gives me an error…but I cannot understand what and why :frowning:

error: SchoolDatabase.swift:20:16: error: cannot convert return expression of type ‘Teacher’ to return type ‘[Teacher]?’
return teacher

Can someone please explain what is wrong and help, please
url: https://www.codecademy.com/courses/learn-intermediate-swift/projects/swift-optionals-school-database