Hi,
Daniel Finnie in another tread help me define a Matrix of essentially
arbitrary dimension as a subclass of Array. He employs a "get"
method to handle a splat of the subscripts. I can't figure out where
this get method is defined. Does anyone have any idea? Code with
examples follow.
Thanks in advance,
Richard
class Matrix < Array
def [] *args
if (args.length == 2) && args[0].is_a?(Integer) && args[1].is_a?
(Integer)
get(*args)
else
super *args
end
end
end
m = Matrix[ [10,20,30], [40,50,60], [70,80,90] ];
puts m [0] [1].inspect # 20
puts m [2] [0].inspect # 70
puts m[1].inspect # [40, 50, 60]