Hal E. Fulton
8/20/2006 6:51:00 AM
Brett Kushner wrote:
> I have used a method of [] with "def method[](string)". But I can't
> figure out how to use[]=.
>
> An array works with []= such as array['string1'] = 'string2' so how
> would I write a method like that for my own class?
>
>
Much the same way -- it will have two parameters.
class MyClass
def []=(index,assigned)
# ...whatever...
end
end
Make sense?
Hal