Created
April 4, 2012 23:07
-
-
Save disnet/2306437 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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