From: Lyle Johnson Date: 2005-01-28T02:36:38+09:00 Subject: Re: [Newbie] Extending Ruby On Fri, 28 Jan 2005 01:56:24 +0900, Asbj�rn Reglund Thorsen wrote: > I am quite new to extending Ruby, and I have read the README.EXT. > I am wondering how to translate (from the code below): > "PyList_SetItem($result, i, PyFloat_FromDouble((double) p(i+1)));" > Into Extending Ruby syntax. The (roughly) equivalent code in a Ruby extension would be: $result = rb_ary_new2(size); for (int i = 0; i < size; i++) rb_ary_store($result, i, rb_float_new((double) p(i+1))); Note that in Ruby you construct an Array instance with a certain initial size by calling rb_ary_new2(size), and then you set the array items by calling rb_ary_store(). Also, the function for constructing a Ruby Float object from a C double is rb_float_new(). Hope this helps, Lyle