1. // The following floating point literal values are equal to 12.1875 in decimal format:
let decimalDouble = 12.1875let exponentDouble = 1.21875e1let hexadecimalDouble = 0xC.3p0//==12+3*(1/16)
2. // type alias. Use the typealias keyword to define the type alias.
typealias AudioSample = UInt16var maxAmplitudeFound = AudioSample.min
3. // tuples
Let http404error = (404, "not found") // The type of http404error is (INT, string), and the value is (404, "not found") Let http200status = (statuscode: 200, Description: "OK") // you can name a single element as let (justthestatuscode, _) = http404errorprintln ("the status code is \ (justthestatuscode)") when defining the tuples )") // output "the status code is 404" println ("the status code is \ (http404error. 0) ") // output" the status code is 404"
4. Use it! To obtain an optional value that does not exist, causing a running error. Use! Before force resolution, you must determine whether to include a non-nil value.
5. Nil in SWIFT is not the same as nil in objective-C. In objective-C, Nil is a pointer to a non-existent object. In swift, Nil is not a pointer -- it is a definite value, used to indicate that the value is missing. The optional status of any type can be set to nil, not just the object type.
June 30, 2014