On Thu, Mar 12, 2020 at 08:51:24AM +0000, mark via Digitalmars-d-learn wrote: [...] > YYY: The range() method is clearly not good D style but I don't know > how to support foreach (item; aaset) ...
The usual idiom is to overload .opSlice, then you can do: foreach (item; aaset[]) { ... } IOW rename .range to .opSlice. > ZZZ: I can't figure out how to support the in operator. Note that 'x in aa' returns a pointer, not a bool. You could try: bool opBinaryRight(string op : "in")(T lhs) { return (lhs in set) !is null; } T -- The richest man is not he who has the most, but he who needs the least.