Thread overview | |||||
---|---|---|---|---|---|
|
December 26, 2010 !in operator | ||||
---|---|---|---|---|
| ||||
Hi, I don't know if it's the right place for this, I prefer forums to newsgroups. Anyway, I am learning D and trying to work with associative arrays. Code (I'm using v1.065 of the DMD compiler): int[char[]] arr; if ("foo" in arr) { }; if ("foo" !in arr) // if (!("foo" in arr)) obviously works { }; unfortunately, only the first "if" statement works, while the second one gives compiler errors: hello.d|72|found '!' when expecting ')'| hello.d|72|found 'in' instead of statement| now, according to http://digitalmars.com/d/1.0/expression.html "The !in expression is the logical negation of the in operation." is it a known bug or am I misunderstanding something? |
December 26, 2010 Re: !in operator | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacek Nowak | Jacek Nowak: > Hi, I don't know if it's the right place for this, I prefer forums to newsgroups. This is the right place. And I think you need to get used to the newsgroups. There is also the IRC #D channel. > now, according to http://digitalmars.com/d/1.0/expression.html "The !in expression is the logical negation of the in operation." is it a known bug or am I misunderstanding something? Isn't the !in present in D2 only? (If this is right, then that's a documentation bug that needs to be reported). Bye, bearophile |
December 26, 2010 Re: !in operator | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacek Nowak | Works in D2, but not in D1. Perhaps this is only a D2 feature?
On 12/26/10, Jacek Nowak <jaceknowak@wp.eu> wrote:
> Hi, I don't know if it's the right place for this, I prefer forums to newsgroups. Anyway, I am learning D and trying to work with associative arrays.
>
> Code (I'm using v1.065 of the DMD compiler):
>
> int[char[]] arr;
>
> if ("foo" in arr)
> {
> };
>
> if ("foo" !in arr) // if (!("foo" in arr)) obviously works
> {
> };
>
>
> unfortunately, only the first "if" statement works, while the second one
> gives
> compiler errors:
>
> hello.d|72|found '!' when expecting ')'|
> hello.d|72|found 'in' instead of statement|
>
> now, according to http://digitalmars.com/d/1.0/expression.html
>
> "The !in expression is the logical negation of the in operation."
>
> is it a known bug or am I misunderstanding something?
>
|
Copyright © 1999-2021 by the D Language Foundation