From: Eric Christopherson Date: 2011-03-28T04:02:05+09:00 Subject: Re: Dynamic classes On Sat, Mar 26, 2011 at 1:16 PM, Vicente Bosch Campos wrote: > I have not explained my self properly. Imagine we are talking about making an instance of any other object e.g. a Car and the car has a name and it allows you reference the car instance by it in the future. > > Would you prefer the car name is defined by the variable that contains it or by setting the name in the constructor? > > hotwheels = Car.new > > current_car = Car.new("hotwheels") > > I don't think anyone would understand directly that I have automatically set a property inside my car with the variable name. It would be a bit counterintuitive and different from how any other instance properties work on this class and how they are usually set on any other type of object of any library. > > Considering the Class to be an object too by not allowing me set the name at the .new and taking the name of the left hand side of the equality sign in case it is a Constant ( otherwise it does not) it is not acting very much like any other object. Is there a way in Ruby to do this with objects generally (i.e. to automatically set a name property upon assignment with =), not just with Classes?