Suggestion: Operator `in` for slices

Nick Treleaven nick at
Sat Jan 1 16:40:02 UTC 2022

On Wednesday, 22 December 2021 at 12:43:26 UTC, Ola Fosheim 
Grøstad wrote:
> What it is conceptually, depends on how you conceptualize it. 
> The most common conceptualization of "in" is as a set operation 
> and you cannot represent a set with array indexes.

`in` is defined for RedBlackTree, but it returns bool:

So aside from the complexity argument, `element in arr` could be 
defined if it returned bool, not a pointer (in order to be 
consistent with AAs not returning a pointer to the *key*). But 
due to time complexity it makes more sense to define `index in 

More information about the Digitalmars-d mailing list