|
Well, that is not elegant (and possibly less efficient) but correct. I would say both milk and cereal in the fridge.
|
|
|
|
|
Whoever wrote that probably has a background in Javascript where you can never be sure if a comparison operator actually converts to a bool.
Latest Article - Code Review - What You Can Learn From a Single Line of Code
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
JavaScript does make one a little twitchy.
cheers
Chris Maunder
|
|
|
|
|
I agree. Those parentheses are totally unnecessary.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
The one you posted has an extra semicolon, right?
bool myVar = (value < 0) ? : true : false;
Ternary operator only has one semicolon.
bool myVar = (value < 0) ? true : false;
But, yes, even the right syntax in this case is a waste, because the result of (value < 0) will result in true or false.
That's what you call your "Double-checking boolean code"
Here's the advanced code for superior programmers who want extreme overkill:
bool myVar = (value < 0)? true : (value > 0 ? false : true);
modified 5-Feb-18 8:28am.
|
|
|
|
|
raddevus wrote: The one you posted has an extra semicolon, right?
It did. Fixed.
raddevus wrote:
bool myVar = (value < 0)? true : (value > 0 ? false : true);
There we go! I knew someone could make the code better!
cheers
Chris Maunder
|
|
|
|
|
raddevus wrote: bool myVar = (value < 0) ? true : false;
raddevus wrote: bool myVar = (value < 0)? true : (value > 0 ? false : true);
That's the "advanced" version with the extra subtle bug that flips the result when value == 0 , right?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
"I meant to do that!"
|
|
|
|
|
And then you wonder what seems wrong when you walk in the door, then remove all confusion when you open the cupboard!
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Colts player Edwin Jackson, Avon man killed by suspected drunken driver[^]
F*** Drunk Drivers straight to the deepest depths of hell.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
IMHO - your title should have been F*** Drunk Drivers, with a link to the Edwin Jackson story.
Anyhow, I agree with your sentiment toward drunk driving.
|
|
|
|
|
BTW - It's also been determined that the drunk was in the country illegally.
|
|
|
|
|
I saw that about an hour ago.
|
|
|
|
|
I was playing Minecraft when my screen went all grayscale. I tried rebooting, but that didn't work. A quick Google lead me to a thread about this, and is appears Win + Ctrl + C will activate a screen filter of some sort. This might be NVidia, but no one in that thread was sure.
That's very annoying.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
So many hidden keystrokes[^], but yeah. Standard Win10 behaviour that's probably impossible to figure out what happened until it happens.
Wait, did I just describe Windows?
TTFN - Kent
|
|
|
|
|
Kent Sharkey wrote: that's probably impossible to figure out what happened until it happens
As opposed to knowing what happened before it happens?
"I'm neither for nor against, on the contrary." John Middle
|
|
|
|
|
Win+Ctrl +C does nothing opn my systemsexcept flas a little graythen go back to normal.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I'd wish there was such a feature for a green-screen.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
How about a Blue screen and a yellow highlighter??
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Not the same as the old green monitor
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I hate poorly-implemented hot keys. The Windows Accessibility subsystem and the Language Bar are two examples.
The Accessibility hot keys actuate if you hold certain keys down for too long. This changes mouse and keyboard behavior, and there's no obvious way to turn them off.
The Language Bar, used to switch between keyboard layouts, has checkboxes for turning features and the bar itself off. Unfortunately, the morons who programmed it don't pay any attention to the settings. The outsourced asshats who do assembly on our machines have a habit of installing [redacted] keyboard and language support. We then get support calls from customers complaining about their machine switching to [redacted] and they can't operate it any longer.
Software Zen: delete this;
|
|
|
|
|
I just saw an update notification the other day (yes, I am well aware I can hide/ignore notifications, but I always like to have the latest) for "Visual Studio 2017 v15.5.6 (<--- notice the "Revision" level update now!) is available."
So, now we are updating Visual Studio and making everyone download and reinstall because a new source code comment was added, or one line was changed? I mean, this is getting ridiculous. It's always great to push the latest out the community I suppose, but can't M$ space the updates out a little bit? It seems like there is an update available practically every time I open VS. So annoying.
Again keeping in mind, I am annoying myself on purpose because I keep insisting to click the "Flag" when it lights up...but hey, I've been to the "DefCon" series of conferences -- I am pathological about keeping the code on my computer patched.
|
|
|
|
|
Quite agree - I've had a moan about VS2017 updates myself here. They are a bit OTT...
|
|
|
|
|
Sounds to me like they are making use of CI(continuous integration) where changes from devs are being pushed to live very quickly.
If that's the case it's very useful for companies like Amazon who are providing SAAS however as you mention for something like Visual Studio it sounds like it would make more sense if the updates were pushed out less frequently and grouped.
It's interesting how something like CI which is seen as the way everyone should be heading has its problems.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
As someone who used to complain that VS was broken and needed more frequent patches and service packs than they were actually getting, I'd rather see more frequent updates that fix actual problems than wait a year or two for the "patch" to take the form of a major version update. In which case a problem might've been fixed, but because it's a new major version, it's got its own set of newer problems.
And I'm saying this as someone who's got a slow internet connection and updates somewhat obsessively.
At least if something's not broken for you, the choice of installing an update or skipping a few of them for a few weeks/months is yours.
But it does get frustrating if you've been putting off updating for a while, finally decide to bring your system up to speed, and then find out the next patch after that was scheduled to come out a day or two later.
|
|
|
|