Hi Ruby friends,
I would like to modify or create own Array#[]= method to return the array.
Currently,
C:\family\ruby>irb
irb(main):001:0> a = [1,2,3,4]
[1, 2, 3, 4]
irb(main):002:0> a[1] = 6
6 <====== returns value inserted
irb(main):003:0> a
[1, 6, 3, 4]
I would like a[1] = 6 to return array a itself, so I can do eg,
a = [1,2,3,4]
p (a[1]=6).sort
I'm reading sir Dave's online axe book so a chapter reference would be fine.
You could also tell me how you search it (since I've search but cannot find
it, maybe my query is not good enough).
Many thanks,
-botp