why $ is need to access array [negative index]?
mw
mingwu at gmail.com
Fri Sep 18 20:56:30 UTC 2020
On Friday, 18 September 2020 at 20:48:47 UTC, bachmeier wrote:
> I'm inclined to say typing a single character is not a hardship
> in exchange for extreme clarity of the code. Keep in mind that
It not about saving "typing a single character".
In the example I showed,
signs[sign] = ...; // the sign can be -1, 0, 1
in D, to write the same code, you have to test the sign and
branch:
if (sign >= 0) {
signs[ sign] = ...;
} else {
signs[$+sign] = ...; // remember + here
}
More information about the Digitalmars-d
mailing list