is vs ==
IchorDev
zxinsworld at gmail.com
Sun Aug 31 11:24:23 UTC 2025
On Saturday, 30 August 2025 at 22:15:26 UTC, Brother Bill wrote:
> Do the Style Guidelines or other authorities prefer one to the
> other for modern D coding?
No: https://dlang.org/dstyle.html
> For the modern D developer, which is the more preferred choice,
> to use 'is' or '=='?
This question doesn't make much sense. It's like if you asked the
same thing about delegates vs functions.
`is` tells you if its operands are exact bit-for-bit matches,
whereas `==` usually compares the contents of two things and may
be overloaded using `opCmp` or `opEquals`.
For clarity's sake, `is` should generally be used for pointer
comparison.
More information about the Digitalmars-d-learn
mailing list