Swift: Initialising parameters in a struct

This entry is part 36 of 41 in the series Swift

Variables are initialised using similar init() function as in a class.

struct Fahrenheit {
    var temperature: Double
    init() {
        temperature = 32.0

var f = Fahrenheit()
print("The default temperature is \(f.temperature)° Fahrenheit")


Series Navigation<< Swift: Optional variable
Swift: Passing parameters in a function call >>