Swift: Class

This entry is part 14 of 41 in the series Swift

In Swift, let let us defines a constant variable.  Notice in the example below, it is used to define an instance of the Music class.

import UIKit

class Music {

    var numRock = 10
    var numCountry = 20
}

let musicGenre = Music()

print(musicGenre.numRock)
print(musicGenre.numCountry)

musicGenre.numCountry = 30
print(musicGenre.numCountry)

swift

Series Navigation<< Swift: Getting the length of a string
Swift: Class member initialization or Constructor >>