On 10/24/2019 05:58 AM, lili wrote:
> Hi:
>     In Dlang where is strange design. The in expression can only use to
> associative array, why array can not use in expression.

In addition to the big O surprise, there is another important issue that may be seen as either for or against supporting the 'in' operator for arrays: With associative arrays, 'in' takes the keys; since keys are index values for arrays, the in operator would be trivially


  return (key < __length
          ? &__ptr[key]
          : null);

Given the two differences, 'in' does not make sense on arrays:

- Big O is different

- One wants to use keys for associative arrays but (likely) values for arrays

Ali

Reply via email to