On Aug 4, 1:47=A0pm, Scott Briggs <scott... / gmail.com> wrote:
> Can someone please explain this behavior in ruby (1.8.6p111):
>
> >> ("2"..."8").to_a
>
> =3D> ["2", "3", "4", "5", "6", "7"]>> ("2".."8").to_a
>
> =3D> ["2", "3", "4", "5", "6", "7", "8"]>> ("2".."9").to_a
>
> =3D> ["2", "3", "4", "5", "6", "7", "8", "9"]>> ("2".."10").to_a
> =3D> []
> >> ("2".."11").to_a
> =3D> []
> >> ("1".."11").to_a
>
> =3D> ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"]


It gets better.

    >> ("100".."11").to_a
    =3D> ["100"]

It seems you're running not so much into strange Range behavior as
strange String behavior in certain numeric circumstances. Or maybe a
combination of strange Range and String behvior. If you want the
ranges to make more sense, use actual numbers.

    >> (2..11).to_a
    =3D> [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

If you want strings in the result, you can get that with a little bit
of work.

    >> (2..11).to_a.map { |x|  x.to_s }
    =3D> ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11"]

--
-yossef