我知道斯威夫特我可以做一个简单的斯威夫特switch语句来计算的值的单变量比较: let distanceTravelled = -145.1
switch distanceTravelled {
case _ where distanceTravelled < 15:
print("You travelled the right distance")
default:
我的应用程序在使用RoShambo方面取得了一些进展,但我难以忍受某种特定的事情。在一个ViewController中,我已经建立了这个类的两个属性。我希望它们是整数,因为我稍后在整数类中使用switch语句。不过,我得到一个错误,当我使用整数说: "Class 'ResultsViewController' has no initializers"
"stored property 'your
var stream: DataStream? = nil
switch stream {
case nil:
print("No data stream is configured.")
case let x?:
print("The data stream has \(x.availableBytes) bytes available.")
}
通过switch