问题描述
我能够在Swift 5中使用局部变量而无需初始化它。什么时候改变了?我当时的印象变量总是需要初始化。
enum Flag {
case a,b
}
func testLocalVar(flag: Flag) {
// No issue here for not initializing testString
var testString: String
switch flag {
case .a:
testString = "A"
case .b:
testString = "B"
}
print(testString)
}
testLocalVar(flag: .a)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)