Hi
I am subclassing the Matrix class, and am having
difficulty getting 'self' for the derived class.
Consider the example below:
module MyMatrix
require 'matrix'
class Matrix < ::Matrix
def add_col(c)
c.to_a.each_with_index { |e,i| @rows[i] << e }
self
end
# def inv
# inv
# self # this doesn't work either
# end
end
end
include MyMatrix
m = MyMatrix::Matrix[[1,2],[3,4]]
puts m.type
puts m.to_f.inv.type
=== output
MyMatrix::Matrix
Matrix
How do I get self to be 'MyMatrix' so I can
chain methods, such as:
m.inv.add_col(c) ?
Thanks
--
Jim Freeze
----------
Political T.V. commercials prove one thing: some candidates can tell
all their good points and qualifications in just 30 seconds.