Click here to Skip to main content
15,887,214 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: if else Style Pin
Jörgen Andersson25-Jan-24 21:20
professionalJörgen Andersson25-Jan-24 21:20 
GeneralRe: if else Style Pin
BernardIE531725-Jan-24 21:39
BernardIE531725-Jan-24 21:39 
GeneralRe: if else Style Pin
Richard MacCutchan25-Jan-24 22:22
mveRichard MacCutchan25-Jan-24 22:22 
GeneralRe: if else Style Pin
Amarnath S25-Jan-24 23:38
professionalAmarnath S25-Jan-24 23:38 
GeneralRe: if else Style Pin
BernardIE531725-Jan-24 23:47
BernardIE531725-Jan-24 23:47 
GeneralRe: if else Style Pin
trønderen26-Jan-24 0:05
trønderen26-Jan-24 0:05 
GeneralRe: if else Style Pin
BernardIE531726-Jan-24 1:04
BernardIE531726-Jan-24 1:04 
GeneralRe: if else Style Pin
trønderen26-Jan-24 1:57
trønderen26-Jan-24 1:57 
Similarly, "if the door is locked" perform the same function as "if the door is locked is true".

In speech, noone that I know of includes the "is true". So why do you program as
C#
if (doorIsLocked == true) ...
rather than
C#
if (doorIsLocked) ...
I see no reason for or advantage of creating a more complex logical expression, adding a second, redundant element. Both "doorIsLocked" and "doorIsLocked == true" are logical expressions, the second one just more complex than it needs to be. (Hopefully, the compiler is able to optimize the redundant element away!)

If I program a test like
C#
if (x < 10 && x < 20) ...
all programmers I know would point out that it is redundant to test for "x < 20" if you already have tested that x < 10.

Adding an extra element a logical expression, to see whether a true "a" is equal to "true" (or that a false "a" is different from "true") is similarly redundant. The logical "a" expression is true or false, all by itself!

Religious freedom is the freedom to say that two plus two make five.

GeneralRe: if else Style Pin
Richard Andrew x6426-Jan-24 5:03
professionalRichard Andrew x6426-Jan-24 5:03 
GeneralRe: if else Style Pin
trønderen26-Jan-24 5:19
trønderen26-Jan-24 5:19 
GeneralRe: if else Style Pin
jschell26-Jan-24 5:49
jschell26-Jan-24 5:49 
GeneralRe: if else Style Pin
PIEBALDconsult27-Jan-24 7:17
mvePIEBALDconsult27-Jan-24 7:17 
GeneralRe: if else Style Pin
Matt Bond29-Jan-24 3:02
Matt Bond29-Jan-24 3:02 
GeneralRe: if else Style Pin
Maximilien26-Jan-24 1:47
Maximilien26-Jan-24 1:47 
GeneralRe: if else Style Pin
BernardIE531726-Jan-24 2:02
BernardIE531726-Jan-24 2:02 
GeneralRe: if else Style Pin
trønderen26-Jan-24 2:06
trønderen26-Jan-24 2:06 
GeneralRe: if else Style Pin
trønderen26-Jan-24 2:26
trønderen26-Jan-24 2:26 
GeneralRe: if else Style Pin
Daniel Pfeffer26-Jan-24 4:09
professionalDaniel Pfeffer26-Jan-24 4:09 
GeneralRe: if else Style Pin
Matt Bond29-Jan-24 3:06
Matt Bond29-Jan-24 3:06 
GeneralRe: if else Style Pin
Greg Utas26-Jan-24 4:42
professionalGreg Utas26-Jan-24 4:42 
GeneralRe: if else Style Pin
0x01AA26-Jan-24 4:55
mve0x01AA26-Jan-24 4:55 
GeneralRe: if else Style Pin
Greg Utas26-Jan-24 5:25
professionalGreg Utas26-Jan-24 5:25 
GeneralRe: if else Style Pin
honey the codewitch26-Jan-24 8:11
mvahoney the codewitch26-Jan-24 8:11 
GeneralRe: if else Style Pin
Mircea Neacsu26-Jan-24 6:02
Mircea Neacsu26-Jan-24 6:02 
GeneralRe: if else Style Pin
honey the codewitch26-Jan-24 7:21
mvahoney the codewitch26-Jan-24 7:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.