You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
irb(main):001:0> (Time.now..(Time.now+60)) === Time.now
TypeError: can't iterate from Time
from org/jruby/RubyRange.java:481:in `each'
from org/jruby/RubyEnumerable.java:1225:in `include?'
from org/jruby/RubyRange.java:710:in `include?'
from org/jruby/RubyRange.java:715:in `==='
from (irb):1:in `<eval>'
from org/jruby/RubyKernel.java:995:in `eval'
from org/jruby/RubyKernel.java:1296:in `loop'
from org/jruby/RubyKernel.java:1115:in `catch'
from org/jruby/RubyKernel.java:1115:in `catch'
from /Users/alexc/.rbenv/versions/jruby-9.1.5.0/bin/irb:13:in `<main>'
The text was updated successfully, but these errors were encountered:
So it looks like MRI does not actually trigger iteration for the == call here while JRuby does. If I actually try to iterate over a range, MRI raises the same error:
[] ~/projects/ruby $ ruby23 -e '(Time.now..(Time.now+60)) === Time.now + 61'
[] ~/projects/ruby $ ruby23 -e '(Time.now..(Time.now+60)).each {}'
-e:1:in `each': can't iterate from Time (TypeError)
from -e:1:in `<main>'
This is telling me that what you expect may not be correct. MRI does appear to try to prevent iteration over a range of Time.
Environment
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 [darwin-x86_64]
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 [darwin-x86_64]
jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 [darwin-x86_64]
Expected Behavior
Under MRI 2.2+
Actual Behavior
The text was updated successfully, but these errors were encountered: