Swift: Class member initialization or Constructor

This entry is part 15 of 41 in the series Swift

In Swift, Class member initialization is implemented using the init function.

import UIKit

class Music {
    var numRock: Int
    var price: Double
    init() {
        numRock = 10
        price = 12.50

let musicGenre = Music()



Series Navigation<< Swift: Class
Swift editor from IBM >>

Leave a comment

Leave a Reply