From: JP Billaud Date: 2011-03-10T08:27:29+09:00 Subject: Re: [Code] Touch Typing Tutor What do you think of my code? Hey, I think your code looks way too much like C. IMO, if you end up using C-like loop statement such as while or for it most likely means you are not doing very good Ruby-like coding. The way I would do your while loop would be something like this: ===== #!/usr/bin/ruby class String def compare_sum_errors other cnt = [self.length, other.length].min (0..(cnt-1)).inject(0) do |errors, idx| next errors + 1 if self[idx] != other[idx] errors end + (self.length - other.length).abs end end str1 = "test origin string" str2 = "test diff string" puts str1.compare_sum_errors str2 ===== Hope it helps, -- Posted via http://www.ruby-forum.com/.