DEV Community

Tomopteris
Tomopteris

Posted on

1 2

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)

Billboard image

📊 A side-by-side product comparison between Sentry and Crashlytics

A free guide pointing out the differences between Sentry and Crashlytics, that’s it. See which is best for your mobile crash reporting needs.

See Comparison

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay