From: Guillaume Cottenceau Date: 2001-09-26T06:19:18+09:00 Subject: [ruby-talk:21685] manipulating "immutable" objects such as Fixnum from within callbacks & al... Hello, Here's the problem: it happens often that you need to pass "references" to objects so that callbacks/functions/etc may modify these objects to their convenience, and you will need the modified value afterwards. Now with "immutable" objects such as Fixnum (also described as objects that have "immediate" values by the pickaxe book --> you can't mutate a given instance) I can't directly do that... and since "everything" is references in Ruby I don't know how to pass a reference to a Fixnum apart doing the following, that is an object which is basically a container holding one object (o) : class ObjContainer attr_accessor :o def initialize(v); @o = v; end end def doit(i); i += 1; end def doit_(j); j.o += 1; end # example of failure t = 3 doit(t) puts t #=> 3 # example of success with ObjContainer k = ObjContainer.new(3) doit_(k) puts k.o #=> 4 Is there a cleaner way to do that ? I tried to look at the toc of the pickaxe, and also grep it out, but I didn't find something... -- Guillaume Cottenceau - http://people.mandrakesoft.com/~gc/