From: "David A. Black" Date: 2008-09-30T19:53:00+09:00 Subject: Re: extend keyword in class definition Hi -- On Tue, 30 Sep 2008, janus wrote: > David > > Am a little confused by your codes, from all I understood in these > threads. > module M > def speak > puts "Hi!" > end > end > > obj = Object.new > obj.extend(M) > obj.speak > > obj.speak should be Object.speak. Why is yours different? And your > second code agreed with singleton idiom. I'm not sure what you mean by "should be". The way it's written, Object does not have a "speak" method, but obj does. That's the effect of extend: it adds module-based functionality to a single object. David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!