Finding position of a value in an array

mw mingwu at gmail.com
Sun Feb 7 00:21:38 UTC 2021


On Saturday, 6 February 2021 at 22:32:53 UTC, Ali Çehreli wrote:
> On 2/6/21 2:26 PM, mw wrote:
>> On Tuesday, 31 December 2019 at 14:52:55 UTC, Steven 
>> Schveighoffer wrote:
>>> On 12/31/19 9:47 AM, Steven Schveighoffer wrote:
>>>
>>>> for the original example:
>>>>
>>>>      int[] a = [77,66,55,44];
>>>>      int i = a.bwin.find(55).bufRef.pos;
>>>
>>> sorry, should be size_t i.
>>>
>> 
>> 
>> Unsigned?
>> 
>> Then how the function signal no such element found?
>> 
>> The convention of indexOf is to use -1.
>> 
>
> I bet it returns size_t.max in that case.


Make it harder to port code from other languages.




More information about the Digitalmars-d-learn mailing list