The interval operator can be used to represent a collection of scopes between two operands
1, closed interval operator: a...b
for inch ... 1024x768 { print (icount)// traversal from 512 to 1024 (including 1024x768) }
2, semi-closed interval operator: A.. <b
ET fruts = ["Apple","Orange","banana" ] = fruts.count for in0.. <icount { print ( i+1) fruit is \ (fruts[i]) }
3, the string range can also use the interval operator
//string InterceptionLet words ="hhggll.com" //do not use interval operatorsLet index = Words.startIndex.advancedBy (3) Let Index2= Words.startIndex.advancedBy (6) Let Range1= range<string.index>(Start:index, end:index2) let RangeStr1=words.substringwithrange (range1) print (RANGESTR1)//using interval operatorsLet Range2 = Words.startIndex.advancedBy (3).. <words.startindex.advancedby (6) Let RangeStr2=words.substringwithrange (range2) print (RANGESTR2) let Hwords="hhggll.com"Let interval="a"..."Z" forCinchHwords.characters {if!Interval.contains (String (c)) {print ("\ (c) is not a lowercase letter") } }
Original link: http://www.hangge.com/blog/cache/detail_513.html
Swift-Interval operator (... And.. <)