Robert Klemme
1/30/2006 5:43:00 PM
Schüle Daniel wrote:
> Hello Robert,
>
>> Btw, what are you trying to accomplish? Somehow I have the feeling
>> that your code might be more complex than needed. Especially the
>> use of a global variable irritates me.
>
> complexity was the intention of my code :)
:-)
> no really, I am playing with metaprogramming, also I wanted to know
> how to implement own functions like "attr_accessor"
One way:
class Module
def i_am_in_class_scope(*a)
p a
end
end
>> class Foo
>> i_am_in_class_scope :foo, :bar
>> end
[:foo, :bar]
=> nil
> btw is there special name for this kind of functions?
> functions that are executed in the class scope and can refer with
> "self" to the class they are inside.
I'd call them "class instance methods".
Kind regards
robert