.
1 var name:String? = "Wing" 2 var geting = "Hello!" 3 if let thisname = name{ 4 geting = "Hello,(name)" //Hello,Wing 5 } 6 else 7 { 8 geting = "Hello,无名氏" 9 }
哎!为什么if判断里是一个赋值?那能有判断吗?哦!原来是判断赋值能否成功,成功则进入if判断体里,flase则进入else。
如果将name = "Wing"改为name = nil则进入else