From: Ryan Lewis Date: 2008-01-16T15:02:00+09:00 Subject: Re: Returning with methods Gary Wright wrote: > > It does. Try > > myusr.inspect.class > > The problem is that IRB has to write that object to stdout so > Array#to_s gets called on the array returned by inspect. > > It is probably a bad idea to break the convention that inspect > returns a string. > > Gary Wright Well, what I'm basically trying to figure out is how to change the a class into another class. Heres my new struct.rb: #!/usr/bin/env ruby class Hash def to_struct(struct_name) Struct.new(struct_name,*keys).new(*values) end end class User def initialize(sn, pw, dob) vars = {:screenname => sn, :password => pw, :dob => Time.parse(dob), :join_date => Time.now, :age => Time.now.year - Time.parse(dob).year} return vars.to_struct("User") end end Now when I call User.new, I want it to turn the User class into the 'vars' Structure -- Posted via http://www.ruby-forum.com/.