Max Williams wrote:
> In a case statement, i know how to use ranges to compare against the
> given variable.  But how do i use < or > ?

Simplest solution is to use a Range with extreme bounds, or use an if 
statement (if age < 25 ...).

The long answer is to explain that

  case foo
  when bar
    ...
  end

is syntactic sugar for

  if bar === foo
    ...
  end

So you can get whatever behaviour you like by creating an object which 
responds to the === method.

class Bounds
  def initialize(meth,val)
    @meth, @val = meth, val
  end
  def ===(other)
    other.send(@meth, @val)
  end
end
def is(meth,val)
  Bounds.new(meth,val)
end

age = 70
case age
when is(:<,25)
  puts "Youngster"
when is(:>,65)
  puts "Oldie"
end

If you wanted this to be more efficient, you could define constants like

UNDER_25 = is(:<,25)
OVER_65 = is(:>,65)

case age
when UNDER_25
  ... etc
end
-- 
Posted via http://www.ruby-forum.com/.