Skip to content

Instantly share code, notes, and snippets.

@nddrylliog
Created February 16, 2010 18:38
Show Gist options
  • Save nddrylliog/305776 to your computer and use it in GitHub Desktop.
Save nddrylliog/305776 to your computer and use it in GitHub Desktop.
// 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