From: Patrick Logan Date: 2001-06-26T13:50:52+09:00 Subject: [ruby-talk:16876] Re: Something strange with Ruby's inheritance mechanism "Eric Jacoboni" wrote in message news:864rt4ruy1.fsf@titine.fr.eu.org... > A Manager "is a" Employee, reverse is not true (that's the classical > assertion...) > > In Ruby, it's legal to assign an Manager to an Employee with > > anEmployee = aManager > > anEmployee is now a Manager... > Is there a way to avoid this behaviour or is it a "feature" ? anEmployee is just a variable name that appears to resemble a class name. In Ruby you can assign any object to be the value of anEmployee, the name is just a convention that documents the *intended* type rather than an *enforced* type. Ruby does not enforce the types of values a variable can refer to. anInteger = "Nope. It's a string" aString = 54321 anEmployee = aString aManager = FrobKnob.new("Not a manager") ....and so on. -- Patrick Logan mailto:patrickdlogan@home.com