标签:
1 import Foundation 2 3 for var i=1; i<=10; i++ { 4 println(i) 5 } 6 7 let str1="adl;fjasdfl;ouewrouqwperuadf" 8 for c in str1 { 9 switch c { 10 case "a","f","o": 11 println(c) 12 13 default: 14 var t="" 15 16 } 17 } 18 var x=1000 19 switch x { 20 case 1...9 : 21 println("个位数") 22 case 10...99: 23 println("十位数") 24 case 100...999: 25 println("百位数") 26 case 1000...9999: 27 println("千位数") 28 default: 29 var t="" 30 } 31 32 var point = (10,10) 33 switch point{ 34 case (0,0): 35 println("0,0") 36 case (1...10,1...10): 37 println("x:\(point.0) - y:\(point.1)") 38 case (_,10): 39 println("xxxxx") 40 default: 41 var t="" 42 } 43 //值绑定 44 switch point{ 45 case (let x,10): 46 println(x) 47 case let(x,y): 48 println("两个值都绑定") 49 case let(x,y) where x == y: 50 println("先判断值是否相等,然后再做绑定") 51 default: 52 var t="" 53 }
标签:
原文地址:http://www.cnblogs.com/lsqandzy/p/4908884.html