From: "David A. Black" Date: 2009-01-10T23:46:23+09:00 Subject: Re: How Ruby Hi -- On Sat, 10 Jan 2009, Stuart Ellis wrote: > > On 9 Jan 2009, at 15:22, LAMBEAU Bernard wrote: > >> Ruby allows you to install methods on objects (called singleton >> methods because installed on individual objects instead of being >> shared by all instances of a class): >> >> o = Object.new >> def o.sayhello >> puts "hello" >> end >> >> o.sayhello # prints hello to the console >> >> blambeau >> > > Now I see - thanks. Also, you can use modules to shape the behavior of individual objects: module Vocal def sayhello puts "Hello" end end o = Object.new o.extend(Vocal) o.sayhello David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!