From: Yossef Mendelssohn Date: 2009-08-05T04:04:57+09:00 Subject: Re: Bizarre Range behavior On Aug 4, 1:47 pm, Scott Briggs wrote: > Can someone please explain this behavior in ruby (1.8.6p111): > > >> ("2"..."8").to_a > > => ["2", "3", "4", "5", "6", "7"]>> ("2".."8").to_a > > => ["2", "3", "4", "5", "6", "7", "8"]>> ("2".."9").to_a > > => ["2", "3", "4", "5", "6", "7", "8", "9"]>> ("2".."10").to_a > => [] > >> ("2".."11").to_a > => [] > >> ("1".."11").to_a > > => ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"] It gets better. >> ("100".."11").to_a => ["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 => [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 } => ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11"] -- -yossef