Skip to content

Instantly share code, notes, and snippets.

@scpike
Created June 23, 2016 14:32
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 scpike/792bf0651960924dbef12b71ca7c0d72 to your computer and use it in GitHub Desktop.
Save scpike/792bf0651960924dbef12b71ca7c0d72 to your computer and use it in GitHub Desktop.
# String#to_i converts a string to an integer:
# "42".to_i # 42
# "0".to_i # 0
#
# Implement a new function atoi(s) which takes a string and converts it to an integer without using to_i:
# atoi("42") # 42
# atoi("0") # 0
#
def atoi(s)
-1 # not the right answer
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment