nobu.nokada / softhome.net wrote:
> Hi,
> 
> At Tue, 30 Mar 2004 04:02:54 +0900,
> Brad Hilton wrote in [ruby-talk:96055]:
> 
>>The code works with ruby 1.8.1, but not with 1.8-cvs or 1.9.
> 
> 
> And works with latest 1.8 and 1.9 in cvs.
> 

I found a simpler example that exposes this strange proc/break problem. 
  There are some weird things going on here.  If I comment out the line 
in initialize(), things work.  If I take out the call to p() in 
initialize(), things work.  If I pass a block of code directly in the 
end of the script instead of creating a proc object (see code below), 
things work.  Can anyone shed some light on what is happening here?

Thanks,
-Brad

------------------------

class DelayedFetcher
   def initialize
     # comment this out to makes things work!?!
     1.times { |i| p i }
   end # initialize

   def fetch(&block)
     rows = []
     10.times { |num|
       rows << { 'i' => num }
     }
     rows.each(&block)
   end
end # DelayedFetcher

# create an object that lazily loads some data
obj = DelayedFetcher.new

data_loader = proc { |hash|
   p hash
   break if hash['i'] == 5
}

# this produces an error...
obj.fetch(&data_loader)

# this works...
obj.fetch { |hash|
   p hash
   break if hash['i'] == 5
}
-----------------------