From: Florian Frank Date: 2003-12-23T10:11:14+09:00 Subject: Re: Does String cache its 'hash' return value? On Tue, 2003-12-23 at 01:56, Asfand Yar Qazi wrote: > What I mean is, if I repeatedly call a String's hash method (i.e. like > using it regularly to access a Hash) will the hash value get > recalculated every time? Yes, it will. Have you considered unsing Symbols instead of Strings? The hash value "calculation" of a Symbol is O(1). -- o=lambda{|o|p o};O=Struct.new(:a,:b,:c);e=%q(_(?h,_(?h,_(?\ ,_(?s,_(?u,_(74)), _(?t)),_(?t,_(?o,_(?n,_(?a))))),_(82,_(?r,_(?e),_(32)),_(32,_(98,_(?u),_(?y))) )),_(?r,_(99,_(97),_(?k,nil,_(?e))),_(10))));def _(*a)O.new(*a)end;class O;def e(&o)b&&b.e(&o);o[a];c&&c.e(&o)end;end;def p(o)print(''<