From: Brian Adkins Date: 2007-10-14T02:55:02+09:00 Subject: Re: Generation of initialize On Oct 13, 8:19 am, arcadiorubiogar...@gmail.com wrote: > Hi everyone, > > I'm new to Ruby. I'm looking for an elegant solution to a simple > problem. > > I have some classes like this one in my code: > > class A > > attr_reader :a1, a2 > > def initialize(a1, a2) > @a1 = a1 > @a2 = a2 > end > > end > > I'm looking for a way in order not to have to define the initialize > method in each class. Struct doesn't fit my needs since due to single > inheritance I can't have any other superclass, and I would like to. Are you looking for something like the following? class A auto_attr_reader :a1, :a2 end a = A.new 7,8 puts a.a1 # -> 7 puts a.a2 # -> 8 You mentioned both wanting to be able to inherit from another class and that you don't want to define initialize, so will all of the classes you wish to inherit from not need initialization?