[Swift] Basics
One, common variables
var str = "Hello, playground"//variable let str1= "Hello xmj112288"//constant//multivariable, note; And, the difference var int1:int32; var str2:string;var int2:int32, Str3:stringvar f1:float=0.1,d1:double=2.1,s1:string= "S1"; Display definition type var char:character = "1"//char definition var num=100000000var num1=100_000_000//digital good-looking definition way var t1= ("XMJ")//Ganso T1. 0t1.1var t2= (age:18,name: "XMJ") t2.aget2.namevar arr1:array<string> = ["1", "2", "3"]//array var dic1:dictionary< string,int32> = ["1": 1, "2": 2]//dictionary func Add (var a:int32,inout b:int32, C:int32 = 3), Int32//function, a without var definition is often InOut reference parameter {a = a+1 B = b+1 return a+b;} var b:int32=5add (1, B: &b)//& reference parameter var ADD1 = Add//function as a variable, note that the parameter with default value becomes without default value such as CADD1 (2,b:&b,c:3) enum E Num1:int32//enum {case E1,e2,e3,e4}var set:set<int32> = [1,2,3,4,4,5,4,3,2]//similar to C # HashSet
var n:int32? Nullable type
var n1 = n!//Gets the value of a nullable type, note that an error when empty;
var q1 = 0...5//Interval
var q2 = 0..<5
[Swift] Basics