DEV Community

Antonio
Antonio

Posted on

Lesson 12 Discussion

  1. How is a method different from a property?

A property expresses an basic quality of an instance, while a method performs an action. Methods have parameters; properties don't. Prefer methods for any call with side effects. If a method does something (for example, it loads, parses, toggles, or prints) or has a verb name, it should not be a property.

2.What is the difference between a type and an instance?

Methods are functions that are associated with a particular type. Classes, structures, and enumerations can all define instance methods, which encapsulate specific tasks and functionality for working with an instance of a given type.

Top comments (0)