Skip to content

Instantly share code, notes, and snippets.

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 Wooder/f74bc827bfe9f18b50bdf2be8721a5c0 to your computer and use it in GitHub Desktop.
Save Wooder/f74bc827bfe9f18b50bdf2be8721a5c0 to your computer and use it in GitHub Desktop.
extension Int {
init?(doubleVal: Doube) {
guard (doubleVal <= Double(Int.max).nextDown) && (doubleVal >= Double(Int.min).nextUp) else {
return nil
}
self.init(doubleVal)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment