Reformat/Refactor a Golfer Class
A simple case of removing unneeded code and fixing broken indentation.
Start file
class Golfer
def initialize; end # initialize
def useless; end;
def self.hello(a,b,c,d)
puts "Hello #{a}, #{b}, #{c}, #{d}"
end
end
End file
class Golfer
def self.hello(*a)
puts "Hello #{a.join(',')}"
end
end
View Diff
2,7c2,4
< def initialize; end # initialize
< def useless; end;
<
< def self.hello(a,b,c,d)
< puts "Hello #{a}, #{b}, #{c}, #{d}"
< end
---
> def self.hello(*a)
> puts "Hello #{a.join(',')}"
> end
Solutions
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
Unlock 1752 remaining solutions by signing in and submitting your own entry
#1753 Patrick Muldoon / @d00n - Score: 206 - 12/29/10 @ 15:12
<Esc>:<Up><Up><Up><Up><Up>g.<BS>/.*def.$<BS>*end.*/d<CR>:v/\S/f<BS>d<CR>fai*<Esc><Right><Right>cf))<Esc><Down><Left>i.join(',')<Esc>lldf:df"a"<Esc>=<Esc><Esc><BS><Up><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>xxxxxi <Down><Down><Esc>x<Up><Right>xx<Esc>:wq<CR>
0 comments