Skip to content

Instantly share code, notes, and snippets.

@disnet
Created April 4, 2012 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disnet/2306437 to your computer and use it in GitHub Desktop.
Save disnet/2306437 to your computer and use it in GitHub Desktop.
class HashMap
# non-implementation of a HashMap :)
get: (key) -> @[key]
put: (key, val) -> @[key] = val
HashMapC = (keyContract, valContract) ->
?{
get: ((keyContract) -> valContract)
put: (keyContract, valContract) -> Any
}
StrHashMap = HashMapC Str, Str
f :: (StrHashMap) -> Any
f = (map) ->
map.get 4
m = new HashMap
m.put 4, "the number four"
f m # contract violation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment