Swift Learning--the use of variable var and let constants (i)

Source: Internet
Author: User

Variable var and let constants in Swift

First introduce the Var and let in Swift

(1) var is an abbreviated form of variable, which is the meaning of the variable and can be changed. Not a data type
Like what:

Note that you do not need to add semicolons after each statement

var i:double=10.0//I is referred to as a double, the variable name is followed by a colon var i = ten  //Assuming that the type is not specified, the system will voluntarily infer the type I = 15//Correct wording according to your assignment


(2) Let is the meaning of a constant. Non-changing

Like what:

Let name:string = "Jhon"//defines the name as a string type, assuming that the program changes below will cause an error.

name = "Hello"//Wrong wording


(3) Splicing string operation

Name+=string (i)  outputs the Jhon10.0

+ = can do string concatenation operation

All Uinicode encoded characters can be declared and used as variable or const names.

Swift Learning--the use of variable var and let constants (i)

Related Article

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.