src/sparse_matrix.rb
# Returns an Array representation of the matrix.
Returns an Array representation of the matrix.
Returns an Array representation of the matrix .
def to_a
        array = Array.new(@height) {Array.new(@width, 0)}
        @sparse_hash.each {|key, value| array[key.x][key.y] = value}
        array
    end
def to_a array = Array . new ( @height ) { Array . new ( @width , 0 ) } @sparse_hash . each { | key , value | array [ key . x ] [ key . y ] = value } array end
Returns an Array representation of the matrix.
Returns an Array representation of the matrix .