Y
Yoann Moreau
Hello, I'd like to use a specific matrix with string as key for lines
and integer index for columns. I could also use string for columns (a
string version of integer), it doesn't matter. I use the matrix to store
a small object (named State) I just need to access data like that :
matrix[a_string][a_number]
Here is how I tried to do it :
matrix = Hash.new{ |hash, key| hash[key] = Array.new(5, State.new(0,
"")) }
But I have strange values, is there a better way to make that matrix ?
and integer index for columns. I could also use string for columns (a
string version of integer), it doesn't matter. I use the matrix to store
a small object (named State) I just need to access data like that :
matrix[a_string][a_number]
Here is how I tried to do it :
matrix = Hash.new{ |hash, key| hash[key] = Array.new(5, State.new(0,
"")) }
But I have strange values, is there a better way to make that matrix ?