From: William James Date: 2007-10-05T00:45:03+09:00 Subject: Re: opinion on a simple method On Oct 3, 11:00 pm, Lloyd Linklater wrote: > 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 > puts IO.read('data').gsub(/\w+/){ $&.capitalize }