Skip to content

Instantly share code, notes, and snippets.

@mrecachinas
Last active December 7, 2016 17:39
Show Gist options
  • Save mrecachinas/1a1a2cfa9c348b9fbcccf83016a799f2 to your computer and use it in GitHub Desktop.
Save mrecachinas/1a1a2cfa9c348b9fbcccf83016a799f2 to your computer and use it in GitHub Desktop.
Public Extension Submission
extension String {
subscript(i: Int) -> Character {
return self[index(startIndex, offsetBy: i)]
}
subscript(r: Range<Int>) -> String {
return substring(with: index(startIndex, offsetBy: r.startIndex)..<index(startIndex, offsetBy: r.endIndex))
}
}
extension Int {
func isPrime() -> Bool {
return self > 1 && !(2..<self).contains { self % $0 == 0 }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment