Created
February 16, 2010 18:38
-
-
Save nddrylliog/305776 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
// HashMap | |
HashMap: class <K, V> { // K = Key type, V = Value type | |
init: func { | |
if(V == NoneType) { | |
// assume string keys! | |
V = K | |
K = String | |
} | |
} | |
} | |
// So we can do: | |
map := HashMap<Int, Int> new() // K = Int, V = Int, int keys, int values | |
// But also: | |
map := HashMap<Int> new() // K = Int, V = NoneType, see `init` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment