L
Lloyd Linklater
I am trying to find the better way to do things ruby style. I needed to
make a method that would read in a file of movie titles and capitalize
each word.
"this is a string".capitalize just gets the first word, so I did this:
File.open('\movies.txt') do |f|
while line = f.gets
s = ""
line.split(/ /).each {|one_word| s += one_word.capitalize + ' '}
puts s.chop
end
end
Is there a cleaner or more "rubyish" way to do this?
make a method that would read in a file of movie titles and capitalize
each word.
"this is a string".capitalize just gets the first word, so I did this:
File.open('\movies.txt') do |f|
while line = f.gets
s = ""
line.split(/ /).each {|one_word| s += one_word.capitalize + ' '}
puts s.chop
end
end
Is there a cleaner or more "rubyish" way to do this?