James Edward Gray II wrote:
> On Aug 19, 2005, at 9:51 AM, Daniel Schierbeck wrote:
> 
>> Could anyone explain to me why this isn't working?
>>
>>     # returns 'no'
>>     case :foo.class
>>       when Symbol then
>>         puts 'yes'
>>       else
>>         puts 'no'
>>     end
> 
> 
> Cases use ===() to do the check in when.  The ===() for class checks  to 
> see if the passed object is of that class.  The object you are  using in 
> the case above is Symbol, which is an object of the class  Class, not 
> the class Symbol you are testing for.
> 
> Put another way, you're outsmarting Ruby's very intelligent case  
> statement.  Let it do all the work:
> 
>     # returns 'yes'
>     case :foo
>       when Symbol
>         puts 'yes'
>       else
>         puts 'no'
>     end
> 
> Hope that helps.
> 
> James Edward Gray II
> 
> 
> 

That worked like a charm! Thank you very much!


Daniel Schierbeck