A converting problem in using "among" with arrays
pascal111
judas.the.messiah.111 at gmail.com
Fri Jul 29 22:32:11 UTC 2022
On Friday, 29 July 2022 at 22:12:54 UTC, Andrey Zherikov wrote:
> On Friday, 29 July 2022 at 22:09:47 UTC, pascal111 wrote:
>> I next code, we have a data type problem
>> "54.among(to!uint[10](y)).writeln;":
>>
>> module main;
>>
>> import std.stdio;
>> import std.string;
>> import std.conv;
>> import dcollect;
>> import std.math;
>> import std.algorithm;
>>
>> int main(string[] args)
>> {
>> int[] x=[23, 34,-88, 54, -90, -34];
>>
>> auto y=x.filter!(a=>a<0);
>>
>> foreach(i; y)
>> i.write(", ");
>>
>> 54.among(to!uint[10](y)).writeln;
>>
>> return 0;
>> }
>>
>> Error message:
>> "hello.d|19|error: only one index allowed to index void|"
>
> Did you mean `to!(uint[10])(y)`? This converts to `uint[10]`.
I want searching for value 54 in array y "54.among(y).writeln;",
but it seems compiler complaints because the data type is
"int[]", so I tried to convert "y" to "uint[]".
More information about the Digitalmars-d-learn
mailing list