From: jasa Date: 2002-03-01T00:18:39+09:00 Subject: Matrix class in Ruby Hi, Today I just played with the Matrix class (file matrix.rb) to solve linear systems. I have the Ruby 1.6.5 Windows distribution from PragProg (archive 'ruby165-2.exe'). I verified that the 'matrix.rb' file is the same in the 'ruby-1.6.6.tar.gz' distribution. The header of this file goes in the end of this email. I was surprised that the class has not the method '[]=', only has the method '[]'. So, I can get one value of the matrix, but I cannot set a value. ^^^^^^ ^^^^^^^^ A TRIVIAL (I'm just a modest Ruby user, not an hacker B-) .... ) addition to 'matrix.rb' put element 'setting' to work. I just created a new method '[]=' as follows ##### the line in matrix.rb is about 280... #accessing #<<<< ALREADY EXISTS def [](i, j) @rows[i][j] end # setting #<<<<< NEW METHOD... def []=(i, j, val) @rows[i][j] = val end My only question is that if there is any reason, that I cannot see, for the method '[]=' not being implemented before ??????? (could Keiju ISHITSUKA reply, please). Is there any danger in setting an element in the matrix? Thanks in advance for any reply. Greetings J. Augusto ------------------------------------------------------------------------------- P.S. The matrix class in the library has the following header (the same as Ruby 1.6.6): #!/usr/local/bin/ruby # # matrix.rb - # $Release Version: 1.0$ # $Revision: 1.11 $ # $Date: 1999/10/06 11:01:53 $ # Original Version from Smalltalk-80 version # on July 23, 1985 at 8:37:17 am # by Keiju ISHITSUKA # .........................