Project

General

Profile

Bug #13044

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

I am working on an app where I need to process various data-items based upon different ruby types. While setting up conditonal-checks, I discovered that "unless" fails to handle plural conditions. 

 Please consider the following example: 

 ~~~ruby ~~~ 
 class ThingA end 
 class ThingB end 
 class ThingC end 

 # obj = ThingA.new 
 # obj = ThingB.new 
 obj = ThingC.new 

 # puts 'yes it is a ThingC' unless obj.is_a?(ThingA) && obj.is_a?(ThingB) # BUG 

 # puts 'yes it is a ThingC' if !obj.is_a?(ThingA) && !obj.is_a?(ThingB) # this works ok 

 # works ok with singular condition 
 unless obj.is_a?(ThingA) 
   unless obj.is_a?(ThingB) 
     puts 'yes it is a ThingC' 
   end 
 end 
 ~~~ 


 Thanks. 

 Regards, 
 Imran 

Back