From: Ned Konz Date: 2001-11-17T02:50:26+09:00 Subject: [ruby-talk:25549] Re: Something strange with Ruby's inheritance mechanism On Friday 16 November 2001 08:11 am, Eric Jacoboni wrote: > That's exactly my problem : A is a subset of B. A subset of objects: a > A object is always a B object, the opposite is not necessary true. My > first post was about the lack of this concept in Ruby: dynamic typing > prevents it as an A object may become, say, an Integer. No. An A object is going to remain an instance of A (or very closely related class if you add methods directly to the instance). Now a variable (i.e. name) that once was bound to an A object may later refer to an integer; there is nothing that requires variables to point to a particular kind of object. However, objects and variables are two very different things. > As beginner in > Ruby, the surprise comes from the fact that the OOP is ok as long as > we stay at the class level but disappears when we come to instances > (object) because of dynamic typing. This trouble comes from my > experience with strong typing languages. Ruby (like Smalltalk) has strong typing, stronger than (say) C++. In Ruby, everything, even numbers, know what type they are. However, variables can refer to objects of any type. -- Ned Konz currently: Stanwood, WA email: ned@bike-nomad.com homepage: http://bike-nomad.com