Preparing for the New DIP Process
FairEnough
FairEnough at gmail.com
Sat Jan 27 02:43:29 UTC 2024
On Saturday, 27 January 2024 at 02:12:25 UTC, FairEnough wrote:
>
> ..
> Any answer to this question has to take into account the other
> code in the module.
Of course, I can answer this question.
The code below demonstrates how D made it possible for me to make
a mistake when I first used D (i.e. I had the unittest in the
same module as the class).
Of course now I know, silly me, just put the unittest in its own
file god-damitt!
But here is how that mistake could have been avoided without
having to put that unittest in its very own module:
module someClass;
class C
{
void increment() {++x;}
private(this) int x;
}
unittest
{
auto c = new C;
c.x++; // it seems to me, that this is not what that 'type'
expects.
c.increment(); // Thanks private(this) for helping me not
make that mistake.
}
More information about the Digitalmars-d-announce
mailing list