The Lounge is rated PG. If you're about to post something you wouldn't want your
kid sister to read then don't post it. No flame wars, no abusive conduct, no programming
questions and please don't post ads.
the integer is not a boolean, but the "success" of the value assignment can be taken as a bool
I have had problems with that several times in my career. That's why I got used to put constants in first place.
if (6 = myInt) is going to throw an error in many more cases as the other possibility.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
Dump() is an extension method added to all objects within LinqPad. LinqPad is a tool which allows writing & compiling simple C# code snippets (plus a bunch of other things). (And the basic version is free: www.linqpad.com )
Plain C operators - it was a stupid mistake from my part, on the same day I made at least 3 mistakes of >= vs >. It wasn just the day - in fact I'm on sick leave today due to a strong headache I've been coddling since yesterday evening. Probably I was starting to feel it's effects in the morning too
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
In that case I needed the first form as I was checking for a flag in a flag register, but mistakenly used the second form due to, well, being the most common (althought not so much in my field, which requires the management of a lot of driverless hardware).
That depends on the language. In a strongly typed language, 1 and true aren't the same because one is a number and true is a boolean. So 2&4 is 0 and 2&&4 is 0 as well, however the difference is in side effects.
SomeFunc & SomeOtherFunc will execute both functions with their side-effets, SomeFunc && SomeOtherFunc will stop executing if SomeFunc returns false.
PS: I am talking about C# here which is, unlike C and C++, a strongly-typed language.