DEV Community

Tomopteris
Tomopteris

Posted on

Swift Lesson 12 Discussion

  1. How is a method different from a property?

A function that can be defined as a part of a type. An example of a “method” would be
“.hasSuffix()”,

in use, you would use an instance in a variable or constant, for example “let example = “Hello””

immediately followed by a period, and then the method: example.hasSuffix()
and the method would return a Boolean.

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

An instance is always related to the type. If your code is
“let example = “String””
your TYPE(example) is a string, and the instance would be in the parenthesis(String).

If it were numerical, it would be
“let numberedExample = 100””

the type(numberedExample) would be an integer, and the instance would be “100” without the quotations.

Top comments (0)