Topic: ruby as a 'dynamic' object-orientated language?

i've often heard it said ruby is a Dynamic Object Orientated environment as one of its major advantages, what does this mean though? compared with say the OO implementation in PHP 5?

thanks

marc

Re: ruby as a 'dynamic' object-orientated language?

PHP 5 and Ruby are almost at opposite ends of the OO spectrum.  PHP has some handy stuff like autoloading of classes (and it actually *has* classes).  There the similarity ends.

Ruby lets you declare a class and then redeclare it.  You can include a class file then open it up and completely overwrite (or rename) certain methods.  You can also construct modules that are like classes but can be included into other classes giving their methods to the including class.

This may seem trivial but it allows for most of the power we see in Rails.

Also, there's the difference that all variables are actually instances of classes with methods that can be called.  There's no such thing as "sometext"=>to_i() in PHP.

Re: ruby as a 'dynamic' object-orientated language?

danger wrote:

Also, there's the difference that all variables are actually instances of classes with methods that can be called.  There's no such thing as "sometext"=>to_i() in PHP.

I love this in Javascript and Ruby (though JS kinda screws it up with Numbers, you can't just do something like 5.times(), it would have to be (5).times() ).

vinnie - rails forum admin