2011/8/14 Chris White <cwprogram / live.com>:
> One way to potentially get around this is to have an object that simple holds a class and overrides the === operator to make case work properly:
>
> class ClassCheck
> def initialize(klass)
>  @holder = klass
> end
>
> def ===(other)
>  @holder == other
> end
> end
>
> klass = 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 = klass
> end
>
> def ===(other)
>  @holder.each { | klass |
>   return true if klass == other
>  }
>  false
> end
> end
>
> klass = 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.


Really great, thanks a lot.

-- 
Iaki Baz Castillo
<ibc / aliax.net>