Class.descendant_of?

B

Ben Johnson

Noob question:

class A; end
class B < A; end

B.kind_of?(A)

Is there a method that will return true if the class is a descendant of
that class?

Thanks for your help.
 
T

Todd Benson

Noob question:

class A; end
class B < A; end

B.kind_of?(A)

Is there a method that will return true if the class is a descendant of
that class?

Thanks for your help.

class A; end
class B < A; end
B.ancestors.include?(A)
=> true

Todd
 
H

Heesob Park

2008/9/3 Ben Johnson said:
Noob question:

class A; end
class B < A; end

B.kind_of?(A)

Is there a method that will return true if the class is a descendant of
that class?
class A; end
class B < A; end

B < A
=> true


Regards,

Park Heesob
 
P

Peña, Botp

RnJvbTogQmVuIEpvaG5zb24gW21haWx0bzpiam9obnNvbkBjb250dWl0aXZlLmNvbV0gDQojIElz
IHRoZXJlIGEgbWV0aG9kIHRoYXQgd2lsbCByZXR1cm4gdHJ1ZSBpZiB0aGUgY2xhc3MgaXMgYSAN
CiMgZGVzY2VuZGFudCBvZiB0aGF0IGNsYXNzPw0KDQpkZXNjZW5kYW50IGlzIHF1aXRlIGEgZ2Vu
ZXJpYyB0ZXJtIDspDQoNCmNvbXBhcmUsDQoNCkIuYW5jZXN0b3JzLm1hcCB7fGJ8ICBbYiwgIEIg
PCBiXX0NCiM9PiBbW0IsIGZhbHNlXSwgW0EsIHRydWVdLCBbT2JqZWN0LCB0cnVlXSwgW0tlcm5l
bCwgdHJ1ZV1dDQoNCkIuYW5jZXN0b3JzLm1hcCB7fGJ8ICBbYiwgQi5zdXBlcmNsYXNzID09IGJd
fQ0KIz0+IFtbQiwgZmFsc2VdLCBbQSwgdHJ1ZV0sIFtPYmplY3QsIGZhbHNlXSwgW0tlcm5lbCwg
ZmFsc2VdXQ0KDQpraW5kIHJlZ2FyZHMgLWJvdHANCg==
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top