From: Rein Henrichs on
On 2010-06-11 00:29:24 -0700, Rein Henrichs said:

> On 2010-06-10 23:41:05 -0700, Une B�vue said:
>
>> I've found in case / when if the case is about a class :
>>
>> case my_var.class
>> when String then puts my_var
>> when Array then my_var.each {|v| puts v}
>> end
>>
>> doesn't work i do have to use :
>>
>> case my_var.class.to_s
>> when 'String' then puts my_var
>> when 'Array' then my_var.each {|v| puts v}
>> end
>>
>> why ?
>>
>> (with ruby 1.9.x)
>
> Because of the behavior of the Module #== operator -- which you can
> look it up at ruby-doc.org -- you can somply do this:
>
> case my_var
> when String then puts my_var
> when Array ...
> end

Woops, that should be Module#=== of course.
--
Rein Henrichs
http://puppetlabs.com
http://reinh.com

From: =?ISO-8859-1?Q?Une_B=E9vue?= on
Jes�s Gabriel y Gal�n <jgabrielygalan(a)gmail.com> wrote:

> You can also do this, but the above is cleaner.

yes of course, clear enough, thanks !

--
� Le verbe aimer est difficile � conjuguer :
son pass� n'est pas simple, son pr�sent n'est qu'indicatif,
et son futur est toujours conditionnel. �
(Jean Cocteau)