From: Oliver Dain Date: 2003-09-05T08:08:06+09:00 Subject: Difference between .. and ... in boolean ranges I'm a bit confused by some Ruby behavior I'm seeing with ranges. As I understand it the difference between 0..5 and 0...5 is that the former includes the number 5 while the 2nd does not. That seems to be the case, but one would expect the same type of behavior in boolean context. For example, I'd think 0.upto(9) do |x| if (x==3)..(x==5) puts "In the range: #{x}" else puts "Not in the range: #{x}" end end Would output: Not in the range: 0 Not in the range: 1 Not in the range: 2 In the range: 3 In the range: 4 In the range: 5 Not in the range: 6 Not in the range: 7 Not in the range: 8 Not in the range: 9 while using the 3 dot form like this: 0.upto(9) do |x| if (x==3)...(x==5) puts "In the range: #{x}" else puts "Not in the range: #{x}" end end Would output: Not in the range: 0 Not in the range: 1 Not in the range: 2 In the range: 3 In the range: 4 Not in the range: 5 Not in the range: 6 Not in the range: 7 Not in the range: 8 Not in the range: 9 However, the 3 dot form doesn't work as expected. It outputs the same as the 2 dot form (which works as expected). What gives? This seems unintuitive to me. Any thoughts? Thanks, Oliver