In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the use of swift". Friends who are interested may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "what is the use of swift"?
You only need to prepare the mac computer before development, and then install xcode.
Note the version. The version of xcode is 10, and the corresponding swift is 4.0.
01
Practice environment
Xcode---File---New---Playground
Open Xcode, select FIle, then create a new New, select create playgroud, select Blank, and select automatically save in a local temporary file.
02
Read the first sentence of code
Var mySwift4:String = "Hello, Mixlab!"
Use var to initialize a variable called mySwift4, the variable type is a String string, and through the = equal sign, assigned, the value of the mySwift4 variable is "Hello, Mixlab!"
Is it like reading English?
Therefore, foreigner programming has natural advantages.
In fact, Chinese characters are also used for programming, such as the screenshot below.
The key to learning programming is to understand the true meaning of each line of code.
Just like we learn a language, we can only master it when we understand the true meaning behind the word.
03
Code comments and readability
The following is combined with comments to understand the code word for word.
After years of practice, reading word for word is beneficial to learning code for the first time.
/ *
Variable declaration and assignment, understand the writing of various variable declarations
Variables can also be declared and not assigned for the time being * /
/ / Writing 1 string literals
Var myString1 = "Hello, Mixlab!"
/ / Writing method 2 instantiation
Var myString2 = String ("Hello, Mixlab!")
/ / Writing 3 you can also add type tags when you declare constants or variables
Var myString3:String = "Hello, Mixlab!"
/ / write 4 statements only
Var myString4:String!
/ / then assign a value to the variable
MyString4 = "Hello, Mixlab!"
/ *
Variables correspond to constants.
Constants are declared using the keyword let
It should be noted that the constant must be defined with an initial value and cannot be modified.
, /
/ / constant writing. You can refer to the first three writing methods of variables and practice by yourself.
Var mix = "code&design"
/ / how do I output the value of a variable?
/ / you can insert constants in a string using parentheses and backslashes
Print ("value of constant mix is\ (mix)")
/ / try print output string length
Print ("the length of constant mix is\ (mix.count)")
Prefix and suffix detection of / / string
Mix.hasPrefix ("code")
Mix.hasSuffix ("design")
/ / the method of traversing strings
For t in mix {
Print (t)
}
/ / string concatenation
Let lab:String = "AI Lab"
Mix = mix + lab
Print (mix)
At this point, I believe you have a deeper understanding of "what is the use of swift?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.