Swift Study Notes 03

Source: Internet
Author: User
1. Assertions
Let age =-3 assert (age> = 0, "a person's age cannot be less than zero") // The assertion is triggered because age <0

2. The SWIFT value assignment operator (=) does not return values, so as to prevent errors caused by writing the place where the equal operator (=) is to be judged as a value assignment. Numeric operators (+,-, *,/, %, etc.) detect that overflow of allowed values is not allowed.

3. When the remainder of Negative B is calculated, the symbol of B is ignored. This means that the results of a % B and A %-B are the same, but-A is different.

4. Unlike C and objective-C, Swift can perform remainder on floating point numbers.
8% 2.5 // equal to 0.5

5. Although one dollar + is useless, when you use a negative number to express a negative number, you can use a positive number to express a positive number, so that your code is symmetrical. (This "symmetric beauty" is good)
Readability is more important than simplicity. Please add parentheses where your code becomes clearer! (Good Habit, like)

6,

Let dollarsign = "\ x24" // $, Unicode scalar U + 0024? Single-byte let Blackheart = "\ u2665 "//?, Unicode scalar U + 2665? Dual-byte let sparklingheart = "\ u0001f496 "//

July 01, 2014


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.