On 8 Nov 2012, at 02:43, Regina George wrote:

> Bartosz Dziewoski wrote in post #1083403:
>> 2012/11/7 Regina George <lists / ruby-forum.com>:
>>> Our challenge was to find out if type confusion was possible in other
>>> languages, and my group got assigned Ruby. Can anyone offer some insight
>>> or point to some resources?
>> 
>> Every variable in your Ruby code in (internally) a C type called
>> "VALUE", which is just a typedefed unsigned int pointer. This pointer
>> points to a larger structure (in C, RBasic and other structs based on
>> it, like RString), from which you can read the value's class and other
>> properties. (Technically, this works differently for Ruby Fixnums and
>> Symbols, whose values are magically encoded in the pointer value
>> itself.)
>> 
>> So it's not possible to have force this kind of behavior you describe
>> in Ruby. However, as 7stud pointed out, instance variables (which are
>> like private fields in Java) can be accessed and modified anyway with
>> a little magic, and private or protected methods can be with some
>> tricks called from the outside environment. This is by design, as far
>> as I know.
>> 
>> -- Matma Rex
> 
> That is really helpful! Thank you! I feel like I understand this a lot > better.

This is a link to a translation of the Ruby Hacking guide http://rhg.rubyforge.org/chapter02.html which I got from this also very useful blog post http://patshaughnessy.net/2012/1/4/never-create-ruby-strings-longer-than-23-characters. There's lots of good stuff in there about how Ruby stores things.

It may help.

Regards,
Iain