Assigning a static array
Brad Anderson
eco at gnuk.net
Thu Apr 18 14:53:25 PDT 2013
On Thursday, 18 April 2013 at 21:45:56 UTC, bearophile wrote:
> Yes, this is supposed to be allowed with the current design of
> D. But with the latest dmd 2.063alpha that code doesn't work,
> see below.
>
> [snip]
>
> Now that code gives a warning:
>
> temp.d(11): Warning: explicit slice assignment this.hash2 =
> (digest(str))[] is better than this.hash2 = digest(str)
>
> (This is the result of a small battle I have started years ago
> that is now half work, thanks to the work of Hara implementing
> my enhancement request. I am glad to see our time was not
> wasted.)
>
> To remove that warning you have to write:
>
> this.hash1 = md5.digest(str);
> this.hash2 = digest!MD5(str)[];
>
> Now it's visible that for hash2 you are slicing something
> that's probably a fixed-sized array. This gives you a
> significant help in understanding what's going on.
>
That's good to hear, Bearophile. Thanks Kenji.
More information about the Digitalmars-d-learn
mailing list