【发布时间】:2014-10-11 02:16:28
【问题描述】:
我已经定义了这个函数:
func need_rebalance() -> (Bool, RebalanceStrategy) {
}
其中 RebalanceStrategy 是枚举类型
enum RebalanceStrategy: String {
case LeftRight = "LeftRight"
case RightLeft = "RightLeft"
}
当我尝试以这种方式打印时,
println("Need rebalance? \(self.need_rebalance())")
我得到这样的输出:
Need rebalance? (false, (Enum Value))
我的问题是:
1) 从元组中提取值是否容易? (希望类似于 python 的东西,例如 self.need_rebalance()[1]。显然这种语法在 swift 中不起作用,因为元组不支持subscript())
2) 如何打印枚举的原始值而不是 (Enum Value)?
我正在使用 XCode6 Beta5
【问题讨论】:
标签: swift tuples xcode6-beta5