Skip to content

Instantly share code, notes, and snippets.

@tcrayford
Created June 15, 2011 15:21
Show Gist options
  • Save tcrayford/1027326 to your computer and use it in GitHub Desktop.
Save tcrayford/1027326 to your computer and use it in GitHub Desktop.
Vim golf challenge
# 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