On Tue, 2008-08-05 at 10:18 +0900, Marcio Braga wrote: > simple code: > > require 'matrix' > m1 = Matrix[[1,2],[3,4]] > > Now I need to change element (0,0) from 1 to 5. I expected something > like the command below should work: > > m1[0][0] = 5 > > ... but the error message is '[]': wrong number of arguments (1 for 2) > (ArgumentError). > > Could someone help me on that ? > Thank you > Marcio IIRC a Matrix (and a Vector) is an immutable object -- you can't change elements individually. You have to copy the Matrix to a (two-dimensional) Array, change the Array element, and then convert the Array back to a Matrix. This is the only violation I've encountered of the rule that you can write FORTRAN programs in any language. :) -- M. Edward (Ed) Borasky ruby-perspectives.blogspot.com "A mathematician is a machine for turning coffee into theorems." -- Alfr¥Æ¥¥d R¥Æ¥¥nyi via Paul Erd¥ÊÁÔ