> Hi, easy example of what I need:
>=20
> -------------------
>  klass =3D String
>=20
>  case klass
>  when String
>    puts "I'm String class"
>  else
>    puts "I'm nothing..."
>  end
> -------------------
>=20
> It produces "I'm nothing...". I understand why:
>=20
> "case" matches the given object using "=3D=3D=3D", and:
>=20
>  String =3D=3D=3D String
>  =3D> false

Correct, because triple equals checks to see if the value is an instance =
or subclass of a class, not if it's the actual class itself

>=20
> while:
>=20
>  String =3D=3D=3D "a new string"
>  =3D> true

Which is why this works. One way to potentially get around this is to =
have an object that simple holds a class and overrides the =3D=3D=3D =
operator to make case work properly:

class ClassCheck
  def initialize(klass)
    @holder =3D klass
  end

  def =3D=3D=3D(other)
    @holder =3D=3D other
  end
end

klass =3D String

case klass
  when ClassCheck.new(String)
    puts "String"
  else
    puts "Nothing"
end

You could also modify it to accept a variable number of arguments to =
check against multiple classes in a single when statement:

class ClassCheck
  def initialize(*klass)
    @holder =3D klass
  end

  def =3D=3D=3D(other)
    @holder.each { | klass |
      return true if klass =3D=3D other
    }
    false
  end
end

klass =3D String

case klass
  when ClassCheck.new(Object, Numeric, String)
    puts "One of these"
  else
    puts "Nothing"
end

This form works with a single class as well.

Regards,
Chris White
http://www.twitter.com/cwgem=