static Object.Object evalHashIndexExpression(Object.Object hash, Object.Object index) { Object.Hash hashObject = (Object.Hash)hash; if (!(index is Object.Hashable)) { return(newError("unusable as hash key: {0}", index.Type())); } Object.Hashable key = (Object.Hashable)index; Object.HashPair pair; if (!hashObject.Pairs.TryGetValue(key.HashKey(), out pair)) { return(NULL); } return(pair.Value); }
static error executeHashIndex(Object.Object hash, Object.Object index) { Object.Hash hashObject = (Object.Hash)hash; if (!(index is Object.Hashable)) { return(string.Format("unusable as hash key: {0}", index.Type())); } Object.Hashable key = (Object.Hashable)index; Object.HashPair pair; if (!hashObject.Pairs.TryGetValue(key.HashKey(), out pair)) { return(push(Null)); } return(push(pair.Value)); }