From: Ian Trudel Date: 2009-02-28T08:56:43+09:00 Subject: Marshal.load does not create new instances? Marshal does not seem to instantiate given class(es) on load. Moreover, it will absolutely work as long as the class is define but even if it has no attributes. The following code snippet creates an array with filled with objects: class Data end data = File.open("data.bin", "rb") { |f| Marshal.load(f) } This absolutely works fine even if the Data class used to dump (e.g. from another program) has many instance variables. They just won't be accessible directly (but still can be accessible using reflection). Inspect would show something like . Furthermore, it doesn't seem to use the defined class if an IO is fed in Marshal.load, thus overriding Data._load just won't work. Is that the expected behaviour? This is really annoying considering that I would like to load data onto one (among many) version of Data class. The version of the class to be used is determined and set at run-time according to the file loaded; this is my ultimate goal. There is obviously no cast feature in Ruby. Even using a proxy won't cut it, if only for the fact that Marshal doesn't instantiate loaded data. Any suggestions? Ian -- Posted via http://www.ruby-forum.com/.