On 10/08/15 11:29, tcak via Digitalmars-d-learn wrote: > I am "trying" to write a function that takes an array of items, and returns > the length of longest item. > > [code] > size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A, > "length" ) ) > { > return 0; // not implemented yet > } > [/code] > > I tried it with > > if( __traits( compiles, A.length ) ) > > as well. But compiler doesn't match it.
Use `A.init.length` instead of `A.length`. You could also use something like if(is(typeof(A.init.length):size_t)) artur