From: Roc Ho Date: 2008-07-03T19:11:11+09:00 Subject: Re: method for assigned value Thanks Hessob and Paul. ----- Original Message ----- From: "Heesob Park" To: "ruby-talk ML" Sent: Thursday, July 03, 2008 5:55 PM Subject: Re: method for assigned value > Hi, > > 2008/7/3 Roc Ho : >> Hello, >> >> Like this: >> class A >> attr_accessor :attr1 >> attr_accessor :attr2 >> end >> >> A.attr1="x" >> A.attr2="y" >> >> Is there any method to code like this : >> >> A = {"x", "y"} >> >> thanks. >> >> > You can use Struct like this: > > S = Struct.new(:attr1,:attr2) > A = S.new('x','y') > > Or > > A = Struct.new(:attr1,:attr2).new('x','y') > > Regards, > > Park Heesob >