From: Lyle Johnson Date: 2004-02-11T01:15:03+09:00 Subject: Re: ruby fixnums Elias Athanasopoulos wrote: > As I have understood Ruby fixnums are passed by value and > you can grab the value as an integer like: > > VALUE foo; > int i = (int) (foo >> 1); > > Is there any way to get an explicit reference of the > value of the fixnum in C, without allocating new space, or using > a new integer pointer? > > I.e. what &RFLOAT(foo)->value does. Well, you have to understand that the internal representation for Fixnum values is different from most other objects in Ruby. If you create two different Float objects with the same value, i.e. x = 5.0 y = 5.0 then they are really two different objects, i.e. x.id != y.id but when you "create" two different Fixnum objects with the same value: x = 5 y = 5 then they are references to the *same* object: x.id == y.id is True So the short answer is no, there's no way to change the value of a Fixnum object like you could with a Float, even from C code. A Fixnum is what it is.