is_a? Method that tells you whether an object has a given class either as its class or as one of its class’s ancestral classes:

>> mag = Magazine.new
=> #<Magazine:0x36289c>
>> mag.is_a?(Magazine)
=> true
>> mag.is_a?(Publication)
=> true

respond_to? – the method that lets you determine in advance whether an object knows how to handle a particular method – can come in handy.

codeByPasha

Author codeByPasha

More posts by codeByPasha

Leave a Reply

All rights reserved Salient.