Robert Klemme
10/4/2007 12:27:00 PM
2007/10/4, 7stud -- <dolgun@excite.com>:
> Robert Klemme wrote:
> >
> > irb(main):001:0> "a b c".each(" ") {|w| p w}
> > "a "
> > " "
> > "b "
> > "c"
> > => "a b c"
> >
> > Note, it'll probably still work.
> >
>
> 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.
Kind regards
robert