大佬教程收集整理的这篇文章主要介绍了Swift:具有多个模式的Switch case无法绑定到变量,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是允许的:
let somePoint = (1,1) switch somePoint { // Case with multiple patterns without binding case (0,_),(_,0): println("(\(somePoint.0),\(somePoint.1)) is on an axis") default: println("(\(somePoint.0),\(somePoint.1)) is not of an axis") }
这也是允许的:
let somePoint = (1,1) switch somePoint { // Case with single patterns with binding case (0,let y): println("(0,\(y)) is on an axis") case (let x,0): println("(\(X),0) is on an axis") default: println("(\(somePoint.0),\(somePoint.1)) is not of an axis") }
但是,这是禁止的:
let somePoint = (1,1) switch somePoint { // Case with multiple patterns that have bindings case (0,let y),(let x,\(y)) is on an axis") default: println("(\(somePoint.0),\(somePoint.1)) is not of an axis") }
以上产生错误:
error: 'case' labels with multiple patterns cAnnot declare variables
以上是大佬教程为你收集整理的Swift:具有多个模式的Switch case无法绑定到变量全部内容,希望文章能够帮你解决Swift:具有多个模式的Switch case无法绑定到变量所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。