Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and Harlan Harris committed Jul 18, 2012
1 parent 84d4374 commit 9fd7bdd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,19 @@ function ht_keyindex{K,V}(h::Dict{K,V}, key)
return -1
end

function get(h::Dict, key, deflt)
function ref{K,V}(h::Dict{K,V}, key)
index = ht_keyindex(h, key)
return (index<0) ? deflt : h.vals[index]
return (index<0) ? throw(KeyError(key)) : h.vals[index]::V
end

function key(h::Dict, key, deflt)
function get{K,V}(h::Dict{K,V}, key, deflt)
index = ht_keyindex(h, key)
return (index<0) ? deflt : h.keys[index]
return (index<0) ? deflt : h.vals[index]::V
end

function key{K,V}(h::Dict{K,V}, key, deflt)
index = ht_keyindex(h, key)
return (index<0) ? deflt : h.keys[index]::K
end

function del(h::Dict, key)
Expand Down

0 comments on commit 9fd7bdd

Please sign in to comment.