Thanks Guy, 
I understand.

> a = A.new({})
> a.value['key'] = 'value'
> p a.value['key']

"a.value" returns @value, and "a.value['key']" means @value['key'].
Oh, great...

Regards,
kwatch


ts <decoux / moulon.inra.fr> wrote in message news:<200203120545.g2C5jth12442 / moulon.inra.fr>...
> >>>>> "k" == kwatch  <kwatch / lycos.jp> writes:
> 
> k>     def value
> k>         @value
> k>     end
>     
> k>     def value=(val)
> k>         @value = val
> k>     end
> 
>  It's best to write it
> 
>        attr_accessor :value
> 
> k> What I want to do is 'b.value[key] = 1'.
> 
> pigeon% cat b.rb
> #!/usr/bin/ruby
> class A
>     def initialize(val=nil)
>         @value = val
>     end
>     attr_accessor :value
> end
> 
> a = A.new({})
> a.value['key'] = 'value'
> p a.value['key']
> pigeon% 
> 
> pigeon% b.rb
> "value"
> pigeon% 
> 
> 
> 
> Guy Decoux