Hi,

David A. Black wrote:
> 
> Yes; you can use a block (among other techniques, like class_eval).
> 
>    c = Class.new do
>      def instance_method
>        puts "hi from instance"
>      end
>      def self.class_method
>        puts "hi from class"
>      end
>    end
> 
>    c.new.instance_method   # hi from instance
>    c.class_method          # hi from class

That looks great, so the Class.initialize method admit a block as a 
parameter and the block becomes on the definition of the Class 
instance.. (I am trying to find the ruby source-code of Class but I can 
not find it on my computer.. :/)

Now, what about inheritance? I mean: how to reproduce the behavior of 
this?:

  class A < B
  end

> 
>> 2) What is the 'class' sentence?, because it is not a instance_method of
>> 'main' that is an instance of Object, the Object#class method returns
>> the name of the class of the instance but not receive any kind of
>> arguments.
> 
> "class" on its own is a keyword, not a method. It's in the same family
> as def, if, case, return, next... and a whole bunch of others.

Yep... simple like this..

Thanks a lot David.

f.
-- 
Posted via http://www.ruby-forum.com/.