From: jzakiya@... (Jabari Zakiya) Date: 2003-09-06T01:30:05+09:00 Subject: Re: Difference between .. and ... in boolean ranges jzakiya@mail.com (Jabari Zakiya) wrote in message news:... > Oliver Dain wrote in message news:... [snip] > > 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 [snip] > ----------------------------------------------------------------- > > change: if (x==3)..(x==5) and (x==3)...(x==5) > to: if (3..5).include?(x) or (3...5).include?(x) > or: if (3..5).include? x or (3...5).include? x > > for second case, you get output: "Not in the range: 5" > > Jabari Zakiya -------------------------------------------------------------------- equivalent oneliners 0.upto(9) {|x| puts (((3..5).include?(x) ? "I" : "Not i") + "n range: #{x}")} 0.upto(9) {|x| print (((3..5).include?(x) ? "I" : "Not i") + "n range: #{x}\n")} 0.upto(9) {|x| print (((3..5).include?(x) ? "I" : "Not i"), "n range: #{x}\n")} Jabari Zakiya