From 9fd7bdd715f10a8a0e545be13869195e41ba988e Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 12 Jul 2012 18:35:37 -0400 Subject: [PATCH] fix #1043 --- base/dict.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/base/dict.jl b/base/dict.jl index e72ab6f193024..2bb82c7214b48 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -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)