From: Chuck Remes Date: 2011-08-25T21:41:43+09:00 Subject: Re: New to Ruby some problems On Aug 25, 2011, at 7:34 AM, jack jones wrote: > First of all thank you very much 7stud :) > okay I got the method but I had a question how would Ruby know what's in > the [ ] and what's out of them > for example : > > class Dog > @array = [] > def []=(arg1, arg2, arg3) > array[arg1 + arg2] = arg3 # any operation > end > end > > > d = Dog.new > d.abc('hello') > d.[1,2]= 3 > # or > d.[1] = 2, 3 > # we have 3 args where to put each?? > # another thing what if I have more than one array > # I'll have to define the method name as def array1[]= (arg1, arg2, > arg3) > # that would be right or wrong?? I don't think we can teach you the entire language on this mailing list. I recommend you take a look at a few books. These are very good but cost a few $$. http://amzn.to/qWRLUg http://amzn.to/r5BdHQ Here's a free one but it's a tad out of date (really only covers Ruby 1.8). http://mislav.uniqpath.com/poignant-guide/ Work through the examples. When you get stuck or confused, drop a note here and we'll try to help. cr