[Issue 2532] '=' does not give a boolean result
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 21 09:49:39 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2532
2korden at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
------- Comment #2 from 2korden at gmail.com 2008-12-21 11:49 -------
It works as designed. It is designed to avoid mistakes.
"if (var = expr) {" is disallowed on purpose to avoid mistakes where you
inteded to write "if (var == expr) {":
int a = ...;
if (a = 42) { // oops, what a typo! I ment if (a == 42) here...
Bool is no different from int in this expression.
However, "if (type var == expression) {" is not a valid construct, so there is
no chance to make a mistake and thus "if (type var = expression) {" is allowed.
There is no 'special cases' for bools.
--
More information about the Digitalmars-d-bugs
mailing list