Hi,

2008/7/3 Roc Ho <hezepeng / huawei.com>:
> 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