good example of assert as expression ?
user1234
user1234 at 12.de
Tue Feb 3 19:58:14 UTC 2026
Following a [previous
thread](https://forum.dlang.org/thread/loojkahtbzigawrscmsr@forum.dlang.org), can you give me good example where the assert expression is useful ?
So far I only see the case where it is used as AndAnd RHS.
```d
void main()
{
auto lhs()
{
extern(C) int rnd;
return (rnd % 1) + 1;
}
lhs() && assert(0);
}
```
I remember an old NG topic where someone asked if D supports the
"assert idiom".
So seriously assert as an expression just works in this context ?
I mean don't you think it's an obscure feature that could be
removed ?
More information about the Digitalmars-d
mailing list