Is "is" the same as ptr == ptr for arrays?

BCS none at anon.com
Sat Aug 7 16:35:53 PDT 2010


Hello Simen,

> simendsjo <simen.endsjo at pandavre.com> wrote:
> 
>> Ok, thanks. Does this mean this equivalent then?
>> 
>> int[] a = [1,2,3];
>> int[] b = a[0..1];
>> assert(a !is b);
>> assert(a.ptr == b.ptr && a.length == b.length);
> Well, no. 

both asserts will fail (a.length == 3 != b.length == 1)

> But what you probably mean, is.
> 
> ( a is b ) == ( a.ptr == b.ptr && a.length == b.length )

I think that is correct.

-- 
... <IXOYE><





More information about the Digitalmars-d-learn mailing list