Created
June 23, 2016 14:32
-
-
Save scpike/792bf0651960924dbef12b71ca7c0d72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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