Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created November 6, 2018 17:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/87d8b128c780a92d5298b167953b4118 to your computer and use it in GitHub Desktop.
Save tenderlove/87d8b128c780a92d5298b167953b4118 to your computer and use it in GitHub Desktop.
begin
Integer("foo", exception: false)
def parse_int string, default
Integer(string, exception: false) || default
end
rescue TypeError
def parse_int string, default
Integer(string)
rescue
default
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment