枚举关联值以及提取
/*
3、枚举关联值
*/
print("\n3、枚举关联值")
enum LineSegmentDes {
case StartAndPattern(start:Double,end:Double)
case StartAndLength(start:Double,length:Double)
}
var les = LineSegmentDes.StartAndPattern(start: 10, end: 20)
les = LineSegmentDes.StartAndLength(start: 10, length: 10)
/*
4、枚举关联值提取
*/
print("\n4、枚举关联值提取")
switch les{
case let .StartAndPattern(s,e):
print("\(s),\(e)")
case .StartAndLength(let s,let l):
print("start:\(s)->length:\(l)")
}