Catalog Index
Breeze Annotated-swift programming language
Point 11.
Numeric type literal
code Example:
- // decimalBinaryinteger = 0b10001 // binaryoctalinteger = 0o21 // Eight- binary 0x11 // 16 binary
Annotations:
Point 12.
Numeric type conversions
code Example:
Let twothousand:uint16 =1= Twothousand + UInt16 (one)
Annotations:
Point 13.
Type aliases
code Example:
Typealias audiosample = UInt16 // the UInt16 type alias is defined as Audiosample // Maxamplitudefound is now 0 .
Annotations:
- A type alias is one that defines another name for an existing type.
- Use the Typealias keyword to define the type alias.
- Once you have defined a type alias, you can use the alias anywhere you can use the original name.
Point 14.
Boolean value
code Example:
True // value is True false // value is False
Annotations:
- Boolean values are logical true or FALSE.
- Swift has two Boolean constants, True and false.
- If a non-Boolean value is used where the Bool type is required, the type safety mechanism of Swift will error.
Point 15.
Meta-group
code Example:
the type of // Http404error is (Int, String), the value is (404, "not Found")let Http404error = (404" Not Found ")
Annotations:
- Tuples combine multiple values into a single composite value.
- The values within the tuple can be any type, do not require the same type, and the order of the types is arbitrary.
- The contents of a tuple can be decomposed into separate constants and variables, and then you can use them normally.
Let (StatusCode, statusmessage) = http404error// output "The status code is 404"println (" The status code is \ (statusCode)")// output" The status message is not Found "println ("Thestatus message is \ (statusmessage)")
- If you only need a subset of the tuple values, you can use the underline (_) to mark the part you want to omit when decomposing.
Let (Justthestatuscode, _) = Http404error// output "The status code is 404"println (" The status code is \ (justthestatuscode)")
- A single element in a tuple can be accessed by subscript, with the subscript starting from zero.
// output "The status code is 404"println ("Thestatus code is \ (http404error.0)") // output "The status message is not Found"println ("Thestatus message is \ (Http404error.1)" /c11>)
- You can name a single element when you define a tuple, and you can get the value of an element by naming it.
$ " OK " )// output "The status codeis a" println ("Thestatus code is \ ( Http200status.statuscode)// output "The status message is OK"println ( " The status message is \ (http200status.description) ")
- Tuples can be used as return values for functions.
The Breeze to Touch Willow (Dashgeng)
Source: http://www.cnblogs.com/dashgeng/
This article starts the blog garden, the copyright belongs to the author all, welcome reprint! This statement must be retained without the consent of the author, and the original text is connected in a prominent position on the article page.Otherwise, the right to pursue legal liability is retained.
Wind notes-swift programming language: point11~15