DEV Community


Posted on

Struct Instruct

One way to create a new type in Swift is by defining a structure, which is often called a struct. A struct is a way of grouping values of other types together. A struct is a better way to define data rather than declaring a series of variables because doing the latter would result in one having to access different arrays possibly with the same index. A struct is a new type, therefore it should begin with a capital letter. Properties should begin with lowercase letters to distinguish values from types, facilitating the reading of the code. I was listening to Coding with Chris on YouTube the other day and he mentioned that a method is the old way of referring to a function. Basically, they are the same… when you think method, think function.

Top comments (0)