On Sunday, 31 July 2022 at 17:03:59 UTC, Salih Dincer wrote:
On Sunday, 31 July 2022 at 15:01:21 UTC, pascal111 wrote:
I don't know how "assert" works, if you explained it I'll be
able to get the idea of your suggestion to apply the
appropriate changes on my code.
**// This code runs forever:**
```d
string str;
assert(str is null);
str = "test";
assert(str !is null);
assert(str.length >= 1);
str = "";
assert(str !is null);
assert(str.length == 0);
int count;
assert(count == 0); // true
assert(true);
while(true) { // endless loop }
```
**// This code runs in a little bit:**
```d
count = 100;
//assert(count); /* or:
assert(count > 1); //*/
while(--count) { }
assert(count); // false and assert error
```
You got the attention by the good understanding of D grammar. I
think I got the idea of "assert".
SDB@79