Skip to content

Commit

Permalink
fix #1043
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 12, 2012
1 parent e44ef83 commit eccf3c5
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 eccf3c5

Please sign in to comment.