From: Robert Klemme Date: 2007-10-05T01:10:07+09:00 Subject: Re: opinion on a simple method On 04.10.2007 16:32, 7stud -- wrote: > Robert Klemme wrote: >> 2007/10/4, 7stud -- : >>> Nice catch! Actually, your solution suffers from the same probem. :( >> I don't think so. Please look again! >> >>> Adding this line corrects mine, and it doesn't slow it down much: >>> >>> IO.foreach("data.txt") do |line| >>> line.each(" ") do |word| >>> next if word == " " >>> print word.capitalize >>> end >>> end >> But it changes white spaces - which my solution does not do. > > Then, I'm not sure what you were pointing out here: > >> Nice idea but: >> >> irb(main):001:0> "a b c".each(" ") {|w| p w} >> "a " >> " " >> "b " >> "c" >> => "a b c" I just wanted to point out that there might be some useless capitalizations going on because of the white space. My solution does not do that because it capitalizes words only. If you will, it's just an aesthetic improvement. :-) > because my original solution and your solution result in the same > output: That's what I said. :-) Kind regards robert