```Martin DeMello wrote:

> Sean O'Dell <sean / cseplsoafmt.com[remove_the_spam]> wrote:
>>
>> Try: if (3..5) === x
>
> Yes, but this is a single boolean not a boolean range. From what I
> understand of the flipflop behaviour, the two dot case behaves like
> this:
>
> flag = true if (x==3)
> if flag
>   body
> end
> flag = false if (x==5)
>
> so by analogy, I'd expect the three dot case to be
>
> flag = true if (x==3)
> flag = false if (x==5)
> if flag
>   body
> end
>
> martin

I think you've got the 2 dot case right, but the 3 dot case is wrong.
Just to make the 2-dot and 3-dot cases look similar, here's another
way to write the 2 dot code:

if flag == true
body
if (x==5) flag = false
else
if (x==3) flag = true
body
if (x==5) flag = false
end

Then the 3 dot case the code is:

if flag == true
body
if (x==5) flag = false
else
if (x==3) flag = true
body
end

The only difference is that if the an x matches both the beginning and
end condition your code doesn't execute body for that x while mine
does:

For example:

0.upto(9) {|x|
if (x==3)...(x==3)
puts "#{x} is a match"
end
}

produces:

3 is a match
4 is a match
5 is a match
6 is a match
7 is a match
8 is a match
9 is a match

your pseudo-code wouldn't have produced any output as x would have set
the flag true, but then immediately set it false and body would never
execute.  What acutally happens is that when x is 3 it sets flag to
true.  The end condition is not checked that iteration in the 3 dot
case.   On the rest of the iterations the end condition is checked
but it is never true so all the rest of the values are output.

Just for reference, here's what the 2 dot case does:

0.upto(9) {|x|
if (x==3)..(x==3)
puts "#{x} is a match"
end
}

produces:

3 is a match

```