jzakiya / mail.com (Jabari Zakiya) wrote in message news:<a6fa4973.0309041930.46e4ab5a / posting.google.com>...
> Oliver Dain <odain2 / nospam.mindspring.com> wrote in message news:<usP5b.8858$tw6.6413 / newsread4.news.pas.earthlink.net>...
[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