# Range Oddity

**URL:** <https://www.ruby-forum.com/t/range-oddity/232988>\
**Category:** JRuby\
**Created:** [November 9, 2014, 7:19am UTC](https://www.ruby-forum.com/t/range-oddity/232988 "2014-11-09T07:19:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [November 9, 2014, 7:19am UTC](https://www.ruby-forum.com/t/range-oddity/232988/1 "2014-11-09T07:19:04Z")

</div>

All -

I’m having a strange issue and am wondering if you might know anything  
about it.

I’m troubleshooting a piece of code that has something like this in it:

0…16.times { … }

I believe the 0… is extraneous and the code should behave as:

0…(16.times { … } )

And the return value of the expression is not used so I think it should  
be  
equivalent to simply:

16.times { … }

However, sometimes when this code is run the block appears to execute 0  
times instead of 16. This happens only when the code is run in JRuby  
(jruby-1.7.16 and jruby-1.6.8 on both OS X and Linux); not on MRI Ruby  
1.9.3 and 2.1.4.

Unfortunately I’m unable to provide a minimal test case.

Does this ring a bell for anyone? Any clue as to what might be  
happening?

Thanks,  
Keith

---

<div class="post-metadata">

**Author:** ![islepilot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/ac8455/32.png) [@islepilot](https://www.ruby-forum.com/u/islepilot)\
**Post date:** [November 9, 2014, 9:17am UTC](https://www.ruby-forum.com/t/range-oddity/232988/2 "2014-11-09T09:17:44Z")

</div>

The 3rd snippet is the only valid style.

Obviously a refactoring uncompleted or untested.
