---恢复内容开始---
.
1 var name:String? = "ZZ" 2 var geting = "Hello!" 3 if let thisname = name{ 4 geting = "Hello,\(name)" //Hello,ZZ 5 } 6 else 7 { 8 geting = "Hello,无名氏" 9 }
哎!为什么if判断里是一个赋值?那能有判断吗?哦!原来是判断赋值能否成功,成功则进入if判断体里,flase则进入else。
如果将name = "ZZ"改为name = nil则进入else
时间: 2024-10-26 19:32:58