From: "Simon Kröger" Date: 2005-09-03T08:02:59+09:00 Subject: Re: Idiomatic conversion of yielding block to array Jacob Fugal wrote: > Good heavens, no! Neither of those are thread safe. Criminy! > > Why not something simple like so: > > require 'enumerator' > > def compare_by_line( expected, actual, message ) > expected_lines = expected.to_enum(:each_line) > actual_lines = actual.to_enum(:each_line) > expected_lines.zip(actual_lines).each_with_index do |pair, index| > assert_equal( *pair, "#{message} on line #{index + 1}") > end > end > > compare_by_line( @html_reference, cal.to_html, "Calendar.to_html incorrect" ) because zip converts each argument to an array, which isn't what you want if there are many lines. > There's no need for threads... True SyncEnumerator does it with continuations but i wasn't ready for this mind bending stuff (yet). (and now i don't need to make knots in my brain, because Levin was so nice to tell us about SyncEnumerator) But what exactly isn't thread safe? SizedQueue is. > Jacob Fugal Threads aren't evil. cheers Simon