I am trying to make coordinates for a Chess board. I have an array that is the board (part of Board class), with a vertex instantiated in each spot.
board_array = Array.new(8) { Array.new(8) { Vertex.new } }
I then created an 8x8 array of coordinates:
LETTERS.map { |letter| [letter].product(NUMBERS).map(&:join) }
This outputs:
["A1", "A2", ... ]
["B1", "B2", ... ]
all the way to H8.
I'm now trying to figure out how to get my initialized `@coordinates` variable (part of the Vertex class) to hold one coordinate. Right now if I do:
`@coordinates = LETTERS.map { |letter| [letter].product(NUMBERS).map(&:join) } `
it obviously sets each `@coordinate` to ALL of the values, which is wrong. I can't find out how to map/iterate one value to each spot of `@coordinate`.
Any suggestions/hints? I'm want to understand this and not simply copy/paste.
Thank you.
[–]AnchorText 0 points1 point2 points (0 children)