On Fri, Oct 14, 2022 at 09:51:54PM +0000, WhatMeWorry via Digitalmars-d-learn wrote: > > I lost about a half an hour troubleshooting some code of mine which as it > turned out to be resolved with just one line. > > > // paths.remove(i); // compiles fine but does nothing > > paths = paths.remove(i); // works - what I erroneously thought the previous > line was doing > > Is the first line nonsensical and should the compiler have at least > issued a warning?
Depending on what your range type was, it may not necessarily do *nothing* (it may mutate the range). But as Andrei put it, "range mutation functions change content, not topology". It *returns* the new "topology", i.e., the new range after the removal; so you need to assign it to the original range in order to keep it up-to-date. Given that this particular trap crops up regularly, perhaps some sort of warning ought to be added. Once the @nodiscard DIP is accepted & implemented this should be easy to do. T -- "I'm running Windows '98." "Yes." "My computer isn't working now." "Yes, you already said that." -- User-Friendly