From: Nasir Khan Date: 2006-06-22T14:52:23+09:00 Subject: Question about Vector class ------=_Part_2196_26060637.1150955540722 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I am extremely new to Ruby, just my first week so I apologize if this has already been discussed or is completely absurd. I was using the library Vector class defined in matrix.rb in one of my programs, the [] method in the library class does not check for range out of bounds and the []= does not even exist. In my program I extended the Vector class as follows - # ------------------------------------------------------------------------------- require 'matrix' # Extend the Vector library class for []= # defined in src/ruby-1.8.4/matrix.rb class Vector include ExceptionForMatrix # []= not defined in the library class def []= (i, val) Vector.Raise ErrDimensionMismatch if i >= @elements.size @elements[i] = val end # Fix the [] in library Vector class def [](i) Vector.Raise ErrDimensionMismatch if i >= @elements.size @elements[i] end end #------------------------------------------------------------------------------- Should this not be part of matrix.rb itself? Best Regards Nasir ------=_Part_2196_26060637.1150955540722--