Swift Study Notes 02

Source: Internet
Author: User
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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.