Dave Thomas wrote:
> 
> Albert Wagner <alwagner / tcac.net> writes:
> 
> > I see some class definitions contain "include" and "extend" statements.
> > I can find no doc refs to these.  Also, "autoload".  If these are in the
> > manual or user guide, please point me in the right direction.  Is there
> > an english translation to ruby-1.4.4/ext/tcltklib/MANUAL.euc?  Thanks
> > ahead for any help.
> 
> Both include and extend take one or more modules and add their methods
> and constants in to something: include adds in to a class definition,
> which extend adds to a particular object.
> 
> For example
> 
>   module Cheery
>     def hello
>       puts "Toodle-pip, old chap!"
>     end
>   end
> 
>   class Person
>     include Cheery
>     def other
>       puts "other"
>     end
>   end
> 
>   p = Person.new
>   p.hello    #=> Toodle-pip, old chap!
>   p.other    #=> other
> 
>   s = "A String"
>   s.extend Cheery
>   s.hello    #=> Toodle-pip, old chap!
> 
> Every language needs Cheery strings.
> 
> Dave
===========================================================
Thanks again, Dave. I understand your example, but not the following
code from ext/tk/lib/tkafter.rb:
:
require 'tk'

class TkAfter
  include TkCore
  extend TkCore
:
:
What does "extend TkCore" do in this class definition? 
Also, in ext/tk/lib/tk.rb:
:
module Tk
  include TkCore
  extend Tk
:
:
What does "extend Tk" do in this module definition?
:
(Am I hopelessly ignorant?)




-- 
Small is Beautiful