Skip to content

Instantly share code, notes, and snippets.

@robkuz
Created December 22, 2011 16:55
Show Gist options
  • Save robkuz/1510985 to your computer and use it in GitHub Desktop.
Save robkuz/1510985 to your computer and use it in GitHub Desktop.
get = "get"
set = (value) -> value
class Grid
@new: (x, y, val = 0)->
item = new Grid x, y, val
(x, y) ->
(value) ->
if value == get
return item.grid[x][y]
else
item.grid[x][y] = value
constructor: (x, y, val = 0) ->
@grid = []
for a in [0...x]
@grid[a] = []
for b in [0...y]
@grid[a][b] = val
grid = Grid.new(3,3)
grid(2,1) set 3
grid(2,2) set 4
console.log grid(2,1) get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment