Test for element in array

Andrei Khropov andkhropov at nospam_mtu-net.ru
Thu Jul 13 16:26:09 PDT 2006


Paolo Invernizzi wrote:

> Hi all,
> 
> Someone can suggest me the best way for testing the presence of an element in
> an array?
> 
> Coming from python, something like...
> 
> if( x in array_of_x && y in array_of_y ){
>    ...
> }
> 
> The workaround, apart from using a simple 'for' loop, is to use an
> associative array, and test for key...
> 
> ---
> Paolo

Despite BCS proposed a cool solution I think 'in' should be built-in for 
usual (non-associative) arrays too. why not?


-- 




More information about the Digitalmars-d-learn mailing list