Code: Select all
class Array2D extends Array {
__new(x, y) {
this.Length := x * y
this.Width := x
this.Height := y
}
__Item[x, y] {
get => base[this.Width * (y-1) + x]
set => base[this.Width * (y-1) + x] := value
}
}
grid := Array2D.new(4, 3)
grid[4, 1] := "#"
grid[3, 2] := "#"
grid[2, 2] := "#"
grid[1, 3] := "#"
gridtext := ""
Loop grid.Height {
y := A_Index
Loop grid.Width {
x := A_Index
gridtext .= grid[x, y] || "-"
}
gridtext .= "`n"
}
MsgBox gridtext
- Warning: This variable appears to never be assigned a value.
Specifically: local base
Line#
000: }
023: {
024: this.Length := x * y
025: this.Width := x
026: this.Height := y
027: }
029: {
---> 029: Return base[this.Width * (y-1) + x]
029: }
030: {
030: Return base[this.Width * (y-1) + x] := value
030: }
034: grid := Array2D.new(4, 3)
035: grid[4, 1] := "#"
036: grid[3, 2] := "#"
Thanks