A converting problem in using "among" with arrays

Andrey Zherikov andrey.zherikov at gmail.com
Fri Jul 29 22:12:54 UTC 2022


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]`.


More information about the Digitalmars-d-learn mailing list