From: tamouse mailing lists Date: 2013-01-08T21:12:22+09:00 Subject: Re: ruby 1.9.3p362 ranges as conditions bug? On Mon, Jan 7, 2013 at 12:01 AM, Matma Rex wrote: > On Mon, 07 Jan 2013 05:26:43 +0100, tamouse mailing lists > wrote: > >> On Sun, Jan 6, 2013 at 9:09 PM, windwiny wrote: >>> >>> vs = (1..9).to_a >>> => [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> >>> v1 = vs.select { |n| if n==3..n==6 then 1 end } >> >> >> What do you expect n==3..n==6 to do? That evaluates to a range of >> booleans, depending on the value of n: > > > These are so-called flip-flops, and a valid though obscure feature of Ruby. > Here's a nicer test case: > > irb(main):001:0> (1..100).each do |i| > irb(main):002:1* puts i if i==42..i==45 > irb(main):003:1> end > 42 > 43 > 44 > 45 > I really do not understand how this works. I can see what it produces, but why?