B
benny
Am Wed, 28 Jan 2004 10:27:35 +0100
I wasn't successful in deleting a key from hash, which is an hash on its own.
h = { {"foo"=>"bar"} =>1 }.delete({"foo"=>"bar"})
doesn't seem to work. any idea?
if there is no way to delete such a key then there would be no difference to "-" :
in both cases the whole entry would be deleted.
{"foo" => "bar"}.delete("foo") = {"foo" => "bar"} - {"foo" => "bar"}
anyway its a very special case to have a key which is a hash, I think. I don't see where such a
thing would make sense and was suprised that its possible (maybe ruby is the only
language to allow such a thing?).
when I think of a "key" I think of a quick index-like reference to find something quickly.
regards benny
schrieb "Robert Klemme said:No, we were talking about "-": If h is a Hash that contains hashes as
keys like h = { {"foo"=>"bar"} =>1 } then how is "h - x" interpreted if x
is a Hash? It's ambiguous.
Regards
robert
I wasn't successful in deleting a key from hash, which is an hash on its own.
h = { {"foo"=>"bar"} =>1 }.delete({"foo"=>"bar"})
doesn't seem to work. any idea?
if there is no way to delete such a key then there would be no difference to "-" :
in both cases the whole entry would be deleted.
{"foo" => "bar"}.delete("foo") = {"foo" => "bar"} - {"foo" => "bar"}
anyway its a very special case to have a key which is a hash, I think. I don't see where such a
thing would make sense and was suprised that its possible (maybe ruby is the only
language to allow such a thing?).
when I think of a "key" I think of a quick index-like reference to find something quickly.
regards benny