Declare a class with properties

 Problem

I want to declare a new class with its own properties, create a new instance and also be able to access its properties.



 Recipe


// Declare our new class

class myClass {

	var myProperty : String
    
    init(prop: String) {
        // Called when a new object is created
        myProperty = prop
    }
    
}

// Create a new object of myClass
let c = myClass(prop:"my property")

print(c.myProperty)
				


 Playground