On Friday, 27 December 2024 at 19:17:13 UTC, JN wrote:
Why not make 'in' work for arrays (and strings also)?

```
int[string] phonebook;
if ("John" in phonebook) // works

int[] numbers;
if (3 in numbers) // doesn't work, compiler recommends std.algorithm.find

string buildLog;
if ("build error" in buildLog) // doesn't work, compiler recommends std.algorithm.find
```


One thing I learned which is somewhat topical--"x in y" is not a boolean expression; its value of the expression is a pointer to the value in the AA. This would break for "string in string" searches, but seems OK for regular arrays.

Andy

Reply via email to