Swift classes and initializers?

Example:


  class Person {
      var name: String
      init(name: String) {
          self.name = name
      }
  }
  let person = Person(name: "John")
  

Solution:

Classes in Swift can have properties and methods. The init method is a special method called an initializer, used to set up the class when an instance is created.

Beginner's Guide to Swift