I have in my code several classes defined using prototype.
var Conversation = Class.create({ (methods) });
var Friend = Class.create({ (methods) });
And I have a variable that can hold an instance of either of both
classes.
var A = new Friend();
Is there a way of checking which type it is?
I''m looking for something equivalent to:
If (A Is Friend) { }
elseif (A Is Conversation) { }
or...
If (typeof A Is Friend) { }
Is there something like that?
I can check for the existence of a member. For example, I know
Conversations have a method called "xxx", and Friends do not, so I can
do:
If (typeof A.xxx != ''undefined'') { }
But that''s bound to be broken when I add an "xxx" method to
Friend.
Plus, I have many different classes a variable can hold, so these
tests can get quite long-winded at times.
Any ideas?
Sorry if this has an obvious answer, I haven''t been able to find it.
Thanks in advance!
Daniel Magliola
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---