From: Marcio Braga Date: 2008-08-05T12:45:47+09:00 Subject: Re: Matrix class: How to set a single element ? Todd Benson wrote: > On Mon, Aug 4, 2008 at 10:24 PM, Marcio Braga > wrote: >> undefined method '[]=' for Matrix[[11, 12], [21, 22]]:Matrix >> (NoMethodError) > > You have to open the class and define the method as in the example... > > class Matrix > def []=(i, j, x) > @rows[i][j] = x > end > end > > Todd Perfect! Thank you. Quick comment: Why this method is not already pre-defined in the Matrix class ? -- Posted via http://www.ruby-forum.com/.