From: Jacob Fugal Date: 2005-09-03T08:27:22+09:00 Subject: Re: Idiomatic conversion of yielding block to array On 9/2/05, Simon Kr�ger wrote: > Jacob Fugal wrote: > > > [...] > > What's the second to last line for? > > > > l = (s1[i] == 10) ? l+1 : l > > > > That will always return false (since s1[i] is always a string, and > > string/integer comparison is always false), so your line count will > > always be 1. > > s1[i] is in fact never a string: Ah, sorry, I missed the fact that you were iterating over characters instead of lines. 10 == ?\n. Gotcha. But isn't that different than the original functionality? He originally wanted a warning (specifically assert_equal as part of Test::Unit) for each line that differed. Your code will only match the first such case then break out of the loop. Jacob Fugal