Day1 (Let and Var)/(String,int,float,double)/(Tuples,contains:array,dictionary)

Source: Internet
Author: User

Let secondsystem:Int = 0b10001

Let eightsystem:Int = 0o21

Let tensystem:Int =

Let sixthsystem:Int = 0x11

SUMMARY:1.U need insert a "Enter" behind equal symbol

Let num_a:Float = 1

Let num_b:Int = 1

Let A:Int = 3

Let B:Double = 0.1415926

Let pi:double = double(a) + b

summary:2.it need change-number ' s type in the same, in order to getting the result

Let bignum_a:Float = Ten/2.5

Let bignum_a2:Int = Ten/3

Let bignum_b:float = float(Int(1.2)) *10.1

Let bignum_c:int = int(3.99)

summary:3.it need change-number ' s type in the same, in order to getting the result

4.forcing number type need add type symbol in the front of number

Let jy = " Love Cooking "

Let address = ". Jianggan,hangzhou City,zhejiang Province,china "

JY + address

Let params = (isloginsuccess:true, Name:"Tommy", Age:)

Let (isloginsuccess,name,age) = params

Let islginsuccess = params. 0

Let whats = params. Name

Let whatsage = params. 2

Let (IsTrue,_,_) = params

If (isTrue)

{

Print("Login success!" )

}

Let Personarray = ("A","B","C","D")

Let Aperson = personarray. 0

Let Bperson = personarray. 1

Summary:5. Tuples

var value_a:Int

Value_a = 1

var imoptionalvariable:Int?

Summary:it ' s equal to nil when the optionalvariable is empty

Imoptionalvariable =

Let name = "Tommy"

var age = Int(name)

If age! = Nil

{

Print("It ' s not empty")

}

else {

Print("It ' s empty!" )

}

Let userage = " "

var currentage = Int(userage)

Let currentnewage = Int(userage)

Summary:string toint use Method:int (String)

If currentage! = nil

{

Print("Age: \(currentage)")

Print("He is" + String(currentage!))

}

If userage . IsEmpty

{

Print("Age: \(userage)")

}Else {

Print("Age:\(userage)")

}

Let Stringa:String? = "optional_string"

Let string2 = "_/stringa"

var stringb = Stringa! + string2

Stringa

Stringa!

Day1 (Let and Var)/(String,int,float,double)/(Tuples,contains:array,dictionary)

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.