Created
January 13, 2017 20:42
-
-
Save eonist/7de94b29f34c72cfc403e9fd74ad9d69 to your computer and use it in GitHub Desktop.
Swift 3 Range overview:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/*Range*/ | |
let a:Range<Int> = 1..<3 | |
print(type(of:a))//Range<Int> | |
a.upperBound//3 | |
/*ClosedRange*/ | |
let b:ClosedRange<Int> = 1...3 | |
print(type(of:b))//ClosedRange<Int> | |
b.upperBound//3 | |
/*CountableRange*/ | |
let c:CountableRange = 1..<3 | |
print(type(of:c))//CountableRange<Int> | |
c.startIndex//1 | |
c.endIndex//3 | |
c.upperBound//3 | |
c.last//2 | |
/*CountableClosedRange*/ | |
let d/*:CountableClosedRange*/ = 1...3 | |
print(type(of:d))//CountableClosedRange<Int> | |
print(d.startIndex)//1 | |
print(d.last!)//3 | |
print(d.endIndex)//past end | |
d.upperBound//3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment