Hah, I wrote that head exploding comment first and then managed to work
out what it did afterwards. Still took a few minutes of smashing my head
into the desk to make room for the new thought though ;¬)
LOL
Using a Hash sounds like a good idea. I already tried rewriting the
selector into something a bit more excel-like (although I won't bore you
with all the little changes):
Good!
def ( addr )
col, row = addr.upcase.scan( /([A-Z]+)(\d+)/ ).flatten
data[ index( row, col ) ]
enddef =( addr, val )
col, row = addr.upcase.scan( /([A-Z]+)(\d+)/ ).flatten
data[ index( row, col ) ] = val
endm = Matrix.new(%w{A B C}, %w{1 2 3 4})
I would probably not initialize the matrix then. Excel is dynamic as
well. So I'd start with a blank slate and only remember a max value
for row and column.
m["A1"] = 123
m["B4"] = 123I haven't gotten around to changing all the "row, col" to "col, row"
references, so it looks a bit weird, but I'm just experimenting with
options at the moment. I'll have a go at Hashing it up as well.
Good. With Ruby, these types of experiments are so much fun. ![]()
Naturally I have many questions floating around in my head, but I'll try
to work them out through the scientific method of repeated failed
attempts
Actually that's probably the best method to learn: we learn much more
through our failures than from our successes.
Kind regards
robert
···
On Fri, Feb 15, 2013 at 3:55 PM, Joel Pearson <lists@ruby-forum.com> wrote:
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/