From: Sharon Phillips Date: 2007-03-10T18:36:17+09:00 Subject: Re: OpenStruct,, know what keys are set On 10/03/2007, at 7:29 PM, Aaron Smith wrote: > I need to use an OpenStruct to mimic what an object acts like in > another > language. is it possible somehow to find what keys are set on an > OpenStruct at any given time? Disclaimer: I'm fairly new to this, so there's a reasonable chance I'm wrong to some degree. Internally, OpenStruct stores the keys as symbols in a hash in an array @table which can be accessed via marshal_dump. Alternatively, you may like to add a method like keys_added: require 'ostruct' class OpenStruct def keys_added @table.keys.map{|k| k.to_s} end end person= OpenStruct.new person.name= "Fred" person.age= 100 person.keys_added => ["age", "name"]