lianliming
12/14/2007 5:18:00 AM
Hi all,
This is a question on Ruby C extension.
I have been hacking some existed ruby c extension, and found following
code:
VALUE klass = rb_define_class(name, pClass);
rb_ivar_set(klass, id_some_var, someValue);
From the book "Programming Ruby, Second Edition", I know the prototype
for rb_ivar_set is like:
VALUE rb_ivar_set( VALUE obj, ID name, VALUE value )
And it says the first parameter should be an obj, while as we can see
from above, the code I am hacking is passing "klass" returned by
rb_define_class to rb_ivar_set.
So I wonder if this is a way to set class variable for a class. I am
really confused because the document says it should be used to set
value of instance variable to a given obj. Am I missing some
knowledge?
Any help is appreciated and thanks in advance!