From: Hugh Sasse Staff Elec Eng Date: 2001-06-26T23:18:13+09:00 Subject: [ruby-talk:16895] Re: Something strange with Ruby's inheritance mechanism On Tue, 26 Jun 2001, Eric Jacoboni wrote: > In fact, "my head" has some problem to justify that there is two > objects of different classes that can be assigned to each other (i'm > rather experienced with strong typing languages). But you don't assign a class to another class. You assign it to a name. Think of the name as a sticky label to put on the class at assignment, if that helps. a = Something.new() b = Something.new() c = a c and a are labels stuck on the same object. b is stuck on another object. Does this help? > > I was considering using Ruby to teach OOP concepts to students but i > don't know how i could justify this behaviour : the "class membership" > concept seems difficult to grasp because of dynamic typing of Ruby and That is different. Class membership is about what methods an object will respond to. a and b above will respond to all the methods of Something. If class AnotherThing < Something #... end then d = AnotherThing.new() d will respond to those methods as well. > one of the main advantage of OOP is this concept (from my point of > vue). I admit my poor knowledge of the language but it's difficult to me > to admit that we can create a class tree and, then, forget it by just > assigning things to others. If you are talking about setting values of instance variables in a class you can ensure they are done through method calls, and only those with access can do it. This has all the advantages you want from OO. > > Dynamic typing has a lot of advantages, but for educationnal issues, Except you may want to educate people about dynamic languages.... > it may hurt. Don't know the Eiffel language (it's the one the students > are currently using to learn OOP concepts), i thought i could use Ruby > instead, that's all... Seems it's not a good idea. > -- > �ric Jacoboni, n� il y a 1296993161 secondes > Hugh