Skip to content

Instantly share code, notes, and snippets.

@airspeedswift
Created June 25, 2015 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save airspeedswift/bc1f71a6d5bb6a008c42 to your computer and use it in GitHub Desktop.
Save airspeedswift/bc1f71a6d5bb6a008c42 to your computer and use it in GitHub Desktop.
Range midpoint
extension Range where T: RandomAccessIndexType {
var mid: T {
return startIndex.advancedBy(
startIndex.distanceTo(endIndex) / 2
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment