海河之家
2014-10-29 22:46
//where
let coordinate2 = (3,3)
switch coordinate2
{
case let (x,y) where x == y:
println("(\(x),\(y)) is on the line x == y")
case let (x,y) where x == -y:
println("(\(x),\(y)) is on the line x == -y")
case let (x,y):
println("(\(x),\(y)) is just some arbitrary point.")
}
let courseInfo = ("3-2","区间运算符")
switch courseInfo
{
case (_,let courseName) where courseName.hasSuffix("运算符"):
println("课程《\(courseName)》是介绍运算符的课程")
default:
println("《\(courseInfo.1)》是其他课程")
}
let courseName = "区间运算符"
switch courseName
{
case let str where str.hasSuffix("运算符"):
println("课程《\(courseName)》是介绍运算符的课程")
default:
println("《\(courseInfo.1)》是其他课程")
}学过scala,发现swift借鉴functional programming的地方特别多。
现在这门课程的前六章已经根据swift正式版的最新语法(基于xcode6.1)进行了更新,同时最新添加了《3-2 nil聚合运算符》和《4-4 String.Index和Range》的最新内容,欢迎收听:)该课程的更新也即将登陆,敬请关注!
是的!感谢分享:)
玩儿转Swift
57356 学习 · 514 问题
相似问题