On 05/11/2012 10:10 PM, Nick Sabalausky wrote:
"Mehrdad"<wfunct...@hotmail.com> wrote in message
news:oksltzwvkdrrjidcn...@forum.dlang.org...
On Friday, 11 May 2012 at 18:16:02 UTC, Alex Rønne Petersen wrote:
On 11-05-2012 20:05, Mehrdad wrote:
6. The 'in' operator returns a pointer (instead of a boolean). Which is
fine, except that it's not what you'd expect in any languages other than
C/C++. i.e. Non-intuitive
I've always found it very intuitive actually... and it saves me from
having to write extra code to do the actual lookup (speed isn't even the
point here, I just want concise code).
Yes, I agree, but consider that D users should NOT have to work with
pointers to do something so basic, like testing to see if something is in
an associative array!
The mere fact that it uses a pointer makes it unintuitive to a large
number of people coming from C#/Java/Python/etc.
I use 'in' all the time, and I never even think about it returning a
pointer. I just do:
if(foo in bar)
And it just works. So I don't see a particularly big problem here.
Try this:
bool fun(){ return foo in bar; }