Passing ruby array values into a C array

故事扮演 提交于 2019-12-04 11:35:20

You can't subscript inputArr because it's a VALUE rather than a C array. Ie, it's a scalar type. To access a particular index, use

rb_ary_entry(inputArr, i)

As an aside, you might want to verify first that it's an array:

Check_Type(rarray, T_ARRAY);

looks like answering the question (and double checking my sources) helped me work out the answer.

replacing:

    rb_ary_push(outputArr, DBL2NUM(X[i][0]));

with:

    x[i][0]=NUM2DBL(rb_ary_pop(inputArr));

seemed to do the trick :)

I'm still wonder if this is the most efficient way of doing things, but it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!