Click here to Skip to main content
15,388,892 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: Cosmetic vs More Efficient Pin
Greg Utas4-May-21 10:01
mveGreg Utas4-May-21 10:01 
GeneralRe: Cosmetic vs More Efficient Pin
W Balboos, GHB5-May-21 1:09
mveW Balboos, GHB5-May-21 1:09 
GeneralRe: Cosmetic vs More Efficient Pin
Greg Utas5-May-21 1:17
mveGreg Utas5-May-21 1:17 
GeneralRe: Cosmetic vs More Efficient Pin
PIEBALDconsult4-May-21 11:04
professionalPIEBALDconsult4-May-21 11:04 
GeneralRe: Cosmetic vs More Efficient Pin
obermd4-May-21 18:48
Memberobermd4-May-21 18:48 
GeneralRe: Cosmetic vs More Efficient Pin
Peter Adam4-May-21 22:07
professionalPeter Adam4-May-21 22:07 
GeneralRe: Cosmetic vs More Efficient Pin
PaltryProgrammer4-May-21 23:09
MemberPaltryProgrammer4-May-21 23:09 
GeneralRe: Cosmetic vs More Efficient Pin
jsc424-May-21 23:31
professionaljsc424-May-21 23:31 
Comments below assume C#, capabilities / syntax in other languages may vary.

My preference is, if internalDefault is not a compile-time constant, to overload the function e.g.
C#
void whatEver() => whatEver(internalDefault);
void whatEver(sometype inVal) { /* ... */ }
or (assuming internalDefault is a compile-time constant)
C#
void whatEver(sometype inVal = internalDefault) { /* ... */ }
Better than null would be to use default(type) e.g.
C#
void whatEver(sometype inVal = default(sometype) { /* ... */ }
But in all of theses you should still check that inVal is not null.
Alternatively, you can use the null coalescing operator e.g.
C#
void whatEver(sometype inVal = null)  // or void whatEver(sometype inVal = internalDefault)
{
   inval = inval ?? internalDefault;
}

One day, perhaps, there will be a null coalescing assignment operator so you can do
C#
inVal ??= internalDefault;
- this is a feature that I have wanted in JavaScript since JS1.1 (c 1998) to change having code like
JavaScript
myvar = myvar || somedefault;
into
JavaScript
myvar ||= somedefault;

GeneralRe: Cosmetic vs More Efficient Pin
Gary Wheeler5-May-21 1:58
MemberGary Wheeler5-May-21 1:58 
GeneralRe: Cosmetic vs More Efficient Pin
W Balboos, GHB5-May-21 2:37
mveW Balboos, GHB5-May-21 2:37 
GeneralRe: Cosmetic vs More Efficient Pin
KateAshman5-May-21 2:27
MemberKateAshman5-May-21 2:27 
GeneralRe: Cosmetic vs More Efficient Pin
W Balboos, GHB5-May-21 2:34
mveW Balboos, GHB5-May-21 2:34 
GeneralRe: Cosmetic vs More Efficient Pin
KateAshman7-May-21 4:25
MemberKateAshman7-May-21 4:25 
GeneralRe: Cosmetic vs More Efficient Pin
Steve Naidamast5-May-21 4:19
professionalSteve Naidamast5-May-21 4:19 
GeneralRe: Cosmetic vs More Efficient Pin
W Balboos, GHB5-May-21 5:21
mveW Balboos, GHB5-May-21 5:21 
GeneralRe: Cosmetic vs More Efficient Pin
Al Gonzalez5-May-21 5:32
MemberAl Gonzalez5-May-21 5:32 
GeneralRe: Cosmetic vs More Efficient Pin
SeattleC++5-May-21 5:57
MemberSeattleC++5-May-21 5:57 
GeneralRe: Cosmetic vs More Efficient Pin
JP Reyes5-May-21 6:35
MemberJP Reyes5-May-21 6:35 
GeneralRe: Cosmetic vs More Efficient Pin
Zuoliu Ding5-May-21 8:08
MemberZuoliu Ding5-May-21 8:08 
GeneralRe: Cosmetic vs More Efficient Pin
W Balboos, GHB5-May-21 8:33
mveW Balboos, GHB5-May-21 8:33 
GeneralRe: Cosmetic vs More Efficient Pin
Zuoliu Ding5-May-21 8:44
MemberZuoliu Ding5-May-21 8:44 
GeneralRe: Cosmetic vs More Efficient Pin
Myron Dombrowski5-May-21 19:43
MemberMyron Dombrowski5-May-21 19:43 
GeneralRe: Cosmetic vs More Efficient Pin
W Balboos, GHB6-May-21 1:44
mveW Balboos, GHB6-May-21 1:44 
GeneralRe: Cosmetic vs More Efficient Pin
Eddy Vluggen6-May-21 9:10
professionalEddy Vluggen6-May-21 9:10 
GeneralRe: Cosmetic vs More Efficient Pin
Gerry Schmitz7-May-21 14:01
mveGerry Schmitz7-May-21 14:01 

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.


Straw Poll

Have you ever taught anyone to code?
"Teaching" can mean from start to finish, or simply just helping someone learning to code work through a coding issue (like helping with homework or being a support tutor)
And how did it go?
  Results   671 votes