Skip to content

Instantly share code, notes, and snippets.

@robkuz
Created December 22, 2011 17:15
Show Gist options
  • Select an option

  • Save robkuz/1511055 to your computer and use it in GitHub Desktop.

Select an option

Save robkuz/1511055 to your computer and use it in GitHub Desktop.
class Grid
@new: (x, y = 1, dval = 0)->
item = new Grid x, y, dval
(x, y) ->
(value) ->
v = value()
if v is undefined
return item.grid[x][y]
else
item.grid[x][y] = v
constructor: (x, y = 1, dval = 0) ->
@grid = []
for a in [0...x]
@grid[a] = []
for b in [0...y]
@grid[a][b] = dval
grid = Grid.new(3,3)
grid(2,1) -> 3
grid(2,2) -> 4
z = grid(2,1) ->
console.log z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment