Notes on The Swift Programming Language-page 27th, swiftlanguage
· Page 27th
1 type safelanguage
The main content on this page is that the swift language is a secure programming language for "type check", meaning that the Left value of the value assignment statement must be the same as the right value, if the left value is declared as a string variable, the right value of the equal sign should be a string caused by double quotation marks, rather than an integer or floating point data.
During code compilation, the compiler checks the left and right values of the value assignment statement. If the type does not match, the compiler reports an error, that is, it checks data security to ensure data consistency.
2 type inferencelanguage
Swift will check the consistency of data types during compilation, but it does not mean that the type of a variable or constant must be specified when defining constants and variables, because swift has a mechanism called type inference language.
The swift language compiler will automatically infer that the constant or variable should belong to that data type based on the initialization value assignment statement of the constant or variable.
Eg1: let s1 = "www. chinagame. me"
Based on the left value of the value assignment statement "www. chinagame. me", swift concludes that the type of the s1 constant is string.
In this way, swift developers do not need to define s1 constants as follows.
Let s1: String = "www. chinagame. me"
Under the type inference mechanism
Let s1 = "www. chinagame. me"
It is equivalent to the let s1: String = "www. chinagame. me" declaration that s1 is a constant.
Keywords: type check, type safe variable agge, type inference
For swift
Swift is good. In fact, it is better to learn the basics. If you learn it directly, you may not understand it in some places. I have some Chinese learning materials. Leave your email and I will give it to you.
Answers to assignments for summer vacation
I lost a black notebook and a red "hero" pen in the reading room on March 13, March 7. If someone finds it, please contact me. Thank you! On October 18, March 7, I picked up a notebook and a pen in the reading room. Please contact XXX of XX class for the error message.