From: Robert Klemme Date: 2007-05-10T21:05:08+09:00 Subject: Re: instance_variables doesn't return unassigned variables On 10.05.2007 12:00, Bernd wrote: > Hi, > I wrote a code like this. > > class ABC > attr_accesor :first, :second > end > > when I wrote the following: > > x = ABC.new > x.first = "test" > puts x.instance_variables > > the output was only > > @first > > Is there a possibility to get also the unassigned variables? I mean, > they exist, but they are only nil. Additionally to the other replies: you can also do something like this: irb(main):001:0> Pair = Struct.new :first, :second => Pair irb(main):002:0> Pair.new.members => ["first", "second"] Kind regards robert