> >>> Below is what I think is a general purpose solution to > >> making > >>> references. I provide several ways to do it. Here is an > >>> example: > >>> > >>> a = (0..5).to_a -> [0,1,2,3,4,5] > >>> w = ref{"a[2..4]"} # uses eval > >>> x = a.ref[2..4] # uses [] and []= methods > >>> y = a.ref("[]","[]=",2..4) # specify methods manually > >>> z = a.ref(["[]",2..4],["[]=",2..4]) # unique args to > >> get/set > >>> [...] > >> > >> This looks very interesting, if only from the toying > >> standpoint. Any > >> chance of you pushing this a bit with a RubyForge project > and > >> a gem release? > > > > I just registered this under the name "reference". > > That might be a somewhat confusing or misleading term, since > Ruby > variables already contain references to objects. Something > with > 'wrapper' in it, or something, maybe? The original intent was to have a way to modify these references that variables contain. This provides a general way of doing this. A side effect is that you can do a lot more though - all you need is a way to get and set the thing you want to access. x = ref{:a} # allows you to get/set the reference that :a has x[] # get the object that :a has x[]=... # set the object reference that :a has Here is another example (pass by reference): def swap(a,b) tmp = a[] a[] = b[] b[] = tmp end swap(ref{:x},ref{:y}) # swap the object references in x and y See how useful this thing is? Yahoo! Mail Stay connected, organized, and protected. Take the tour: http://tour.mail.yahoo.com/mailtour.html