Methods

    Key Points:

    • It can be helpful to introduce methods by comparing them to functions.
      • Methods are called on an instance of a type (such as a struct or enum), the first parameter represents the instance as self.
    • Point out the use of the keyword self, a method receiver.
      • Show that it is an abbreviated term for and perhaps show how the struct name could also be used.
      • Note how is used like other structs and dot notation can be used to refer to individual fields.
      • This might be a good time to demonstrate how the &self differs from self by modifying the code and trying to run say_hello twice.