帮助我了解法典的这一部分:
class Ooo
attr_accessor :class_array
end
def func(ctx)
local_array = ctx.class_array
local_array = [4,3,5,5,6]
return
end
aaa = Ooo.new
func(aaa)
aaa.class_array => not [4,3,5,5,6] :-(
I supposed that ruby use addresses when operates with arrays... Why does this code not work? I want to do this (in C):
struct ctx
{
uint class_array[10000]
}
void func(struct *ctx)
{
uint* local_array = &ctx->class_array
local_array[0] = 4;
ctx->class_array[0] => 4
}