Suggestion: Operator `in` for slices

Nick Treleaven nick at
Tue Dec 21 17:06:04 UTC 2021

On Monday, 20 December 2021 at 21:11:28 UTC, Ola Fosheim Grøstad 
> You can always create a library construct, but then you should 
> also argue in favour of removing AAs and "in". You either do 
> it, or you don't. Why the half-measures?

No, `canFind` and `among` search for a given value in a range. 
`in` checks if a given key exists and returns a pointer to the 
associated data (not a pointer to the matching key). This is why 
Phobos SortedRange does not implement opIn even though it would 
be sub-linear. Dennis is right that conceptually a key for an 
array is an index. An array element value is the data associated 
with an index.

More information about the Digitalmars-d mailing list