Hello All,
I want to know that is there anything in ruby by which i can know that
which kind of object is this…? Something like is_object?
I mean… lets suppose i have two objects of Model ABC and Model DEF…
then i want to execute some conditions based upon the type of objects.
Thanks in advance.
I think instance_of can serve my purpose.
Hemant B. wrote:
Hello All,
I want to know that is there anything in ruby by which i can know that
which kind of object is this…? Something like is_object?
I mean… lets suppose i have two objects of Model ABC and Model DEF…
then i want to execute some conditions based upon the type of objects.
Thanks in advance.
On Fri, Jul 9, 2010 at 03:56, bala kishore pulicherla
[email protected] wrote:
use object.class
Just beware, if you do a direct comparison, you won’t catch subclasses.
-Dave
–
Dave A. - Have Pun, Will Babble | Work: davearonson.com | /\ ASCII
-------------------------------------+ Play: davearonson.net | / Ribbon
“Specialization is for insects.” | Life: dare2xl.com | /\
Campaign
-Robert A. Heinlein | Wife: nasjleti.net |
Email<>Web
$ irb
class MyHash < Hash ; end
=> nil
h = MyHash.new
=> {}
h.is_a? Hash
=> true
Cheers,
Andy
–
Andy J.
http://andyjeffries.co.uk/ #rubyonrails #mysql #jquery
Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS
Company number: 5452840