Methods are functions that are associated with an instance of a class or structure. A method, like a function, will encapsulate the code for a specific task or functionality that is associated with the class or structure. Let's look at how we can define methods for classes and structures. The following code will return the full name of the employee by using the firstName and lastName properties:
func getFullName() -> String { return firstName + " " + lastName }
We define this method exactly as we would define any function. A method is simply a function that is associated with a specific class or structure, and everything that we learned about functions in the previous chapters applies to methods. The getFullName() function can be added directly to the EmployeeClass class or EmployeeStruct structure without any modification.To access a method, we...