From: Ryan Leavengood Date: 2005-10-03T03:10:46+09:00 Subject: Re: C++ equivs in Ruby On 10/2/05, Pascal GUICHARD wrote: > my point is : > - on pymorphism, i have seen ruby code that is testing what is the type > (class, name) that is calling this pice of code, and that sounds very > strange to me, In this case the polymorphism based on types that C++ and Java might do has to be done by hand in Ruby, since parameters are typeless. But in most cases this is not needed and usually "duck typing" is used, in other words if a particular variable responds to certain messages (quacks like a duck), that is all we care about. For example a method that can take either Symbols or Strings could always call to_s on the parameter being passed in, since both Symbol and String implement this method (in the case of String it just returns itself.) If things aren't quite so convenient then parameters can be queried with the responds_to method to see if they respond to a particular method before that method is called. > - on pointers, i try to understand (howto implement) datastructures in which > you need to mix values and references/poiters You just don't have to worry about this in Ruby. Forget that the pointer type even exists. For example if you have a linked list, each node won't consist of a pointer and data, it will consist of two references, one which points to the next node, and one which points to some kind of data (that could be any type.) Ryan