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