Break handling discrepancy between JRuby and MRI
------------------------------------------------

                 Key: JRUBY-2526
                 URL: http://jira.codehaus.org/browse/JRUBY-2526
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.1.1
         Environment: Ubuntu 8.04, i386, Sun Java 1.6.0_06, JRuby binary from 
jruby.org
            Reporter: Shot


Given the below Enumerable extension:

module Enumerable
  def every_pair_with_indices
    each_with_index do |a, i|
      each_with_index do |b, j|
        yield [a, b, i, j] if i < j
      end
    end
  end
  def every_pair
    every_pair_with_indices do |a, b, i, j|
      yield [a, b]
    end
  end
end

when breaking out of Enumerable#every_pair, JRuby 1.1.1 seems to break only out 
of the final implementation's inner loop, while MRI 1.8.6.p114 breaks out of 
the whole #every_pair (much like it would break out of #each):

ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-linux]
>> [1,2,3,4].every_pair{|a,b| p [a,b]; break if [a,b] == [1,3]}
[1, 2]
[1, 3]
=> nil

ruby 1.8.6 (2008-04-22 rev 6555) [i386-jruby1.1.1]
>> [1,2,3,4].every_pair{|a,b| p [a,b]; break if [a,b] == [1,3]}
[1, 2]
[1, 3]
[2, 3]
[2, 4]
[3, 4]
=> [1, 2, 3, 4]

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to