First, mind map
Second, the Code
//This will make the code very ugly . ifX! = Nil && Y! =Nil {print ("x or Y are not equal to null")} print ("x or Y has an empty") //1 use??Let name:string? ="I am the most handsome"Let age:int= - //?? Represents a selectable unpacking package//The following two execution results behave differently due to changes in values,Print (name??""+ String (age))//I'm the most handsome, because he has the lowest priorityPrint (name??"") + String (age))//I am the most handsome 18, because of the parentheses, the priority level will be very high// //1 Using if letLetNew: String? ="the new type"Let oage:int? = -//if let new = new,//Let oage = oage {//Print (new+string (oage))//}else{//print ("New or Oage is empty")// } //use guard let, preceded by the newly defined name, with the use of the If let exact oppositeGuard Let Onew =New, let ages = OageElse{print ("new or oage is empty") return} print (Onew+ String (Ages))
Swift optional type (optional)---Introduction to Swift