Swift – Structures
Structures is used to represent a collection of different types. In swift, it is possible to have initializers and methods like classes. The most common difference is that class instance is passed as reference and structure is passed as copy.
Syntax
struct structureName{ //variables and methods } // Structure initialization let variableName = structureName(variable1:initialValue1,...,variablen:initialValuen)
Example
struct Student{ var name:String var rollNo:String func desc()->String{ return "The name of student with roll number\(rollNo) is \(name)" } }