You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
print("The width of someResolution is \(someResolution.width)")
// Prints "The width of someResolution is 0"
print("The width of someVideoMode is \(someVideoMode.resolution.width)")
// Prints "The width of someVideoMode is 0"
someVideoMode.resolution.width =1280print("The width of someVideoMode is now \(someVideoMode.resolution.width)")
// Prints "The width of someVideoMode is now 1280"
Memberwise Initializers for Structure Types
letvga=Resolution(width:640, height:480)
Structures and Enumerations Are Value Types
lethd=Resolution(width:1920, height:1080)varcinema= hd
cinema.width =2048
print("cinema is now \(cinema.width) pixels wide")
// Prints "cinema is now 2048 pixels wide"
print("hd is still \(hd.width) pixels wide")
// Prints "hd is still 1920 pixels wide"
enumCompassPoint{case north, south, east, west
mutatingfunc turnNorth(){self=.north
}}varcurrentDirection=CompassPoint.west
letrememberedDirection= currentDirection
currentDirection.turnNorth()print("The current direction is \(currentDirection)")print("The remembered direction is \(rememberedDirection)")
// Prints "The current direction is north"
// Prints "The remembered direction is west"
Classes Are Reference Types
lettenEighty=VideoMode()
tenEighty.resolution = hd
tenEighty.interlaced =true
tenEighty.name ="1080i"
tenEighty.frameRate =25.0
print("The frameRate property of tenEighty is now \(tenEighty.frameRate)")
// Prints "The frameRate property of tenEighty is now 30.0"
Identity Operators
if tenEighty === alsoTenEighty {print("tenEighty and alsoTenEighty refer to the same VideoMode instance.")}
// Prints "tenEighty and alsoTenEighty refer to the same VideoMode instance."