Created
June 15, 2011 15:21
-
-
Save tcrayford/1027326 to your computer and use it in GitHub Desktop.
Vim golf challenge
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
# Turn the first block of code into the second one | |
# Starting on the 'r' of return | |
def add(string) | |
if /,/.match string | |
return string.split(',').map(&:to_i).inject(0, &:+) | |
end | |
if string.empty? | |
0 | |
else | |
string.to_i | |
end | |
end | |
def add(string) | |
if string.empty? | |
0 | |
else | |
string.split(',').map(&:to_i).inject(0, &:+) | |
end | |
end | |
# Initial attempt(Tom Crayford): dwdd3jpjdd:4dj |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment