Click here to Skip to main content
15,897,226 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: Hayabusa 2 rovers send new images from Ryugu surface Pin
Nelek28-Sep-18 8:17
protectorNelek28-Sep-18 8:17 
GeneralWSO CCC OTD Solution Pin
OriginalGriff28-Sep-18 2:03
mveOriginalGriff28-Sep-18 2:03 
GeneralRe: WSO CCC OTD Solution Pin
super28-Sep-18 2:09
professionalsuper28-Sep-18 2:09 
GeneralRe: WSO CCC OTD Solution Pin
OriginalGriff28-Sep-18 2:24
mveOriginalGriff28-Sep-18 2:24 
QuestionAny language supports this type of syntax? Pin
Eytukan28-Sep-18 1:58
Eytukan28-Sep-18 1:58 
AnswerRe: Any language supports this type of syntax? Pin
Pete O'Hanlon28-Sep-18 2:05
mvePete O'Hanlon28-Sep-18 2:05 
GeneralRe: Any language supports this type of syntax? Pin
Eytukan28-Sep-18 2:16
Eytukan28-Sep-18 2:16 
GeneralRe: Any language supports this type of syntax? Pin
Eric Lynch28-Sep-18 2:27
Eric Lynch28-Sep-18 2:27 
Not nearly as performant as the original. Though, if avoiding repetition is the OPs goal, a couple of other C# possibilities include: Smile | :)

C#
int n = nThatVeryLongVariableYourMateNamed;
if (n == 0 || n == 1 || n == 2)
{
}

C#
switch(nThatVeryLongVariableYourMateNamed)
{
  case 0:
  case 1
  case 2
    break;
}

C#
private static readonly HashSet<int> validValues = new HashSet<int> { 0, 1, 2};
.
.
.
if (validValues.Contains(nThatVeryLongVariableYourMateNamed))
{
}

C#
if (new int[] { 0, 1, 2}.Contains(nThatVeryLongVariableYourMateNamed))
{
}


In answer to the original question, I think there are some languages that support syntactic sugar for creating/checking sets. Though, none I commonly use. If I recall, in my hazy memory, I think the largely dead PASCAL language used to have such support Smile | :)

In general, it's not much of a problem. Almost all languages, have a decently concise syntax for creating/checking sets. They simply do away with the fluff of formalizing it as a separate concept in the language.
GeneralRe: Any language supports this type of syntax? Pin
G3Coder28-Sep-18 3:21
G3Coder28-Sep-18 3:21 
GeneralRe: Any language supports this type of syntax? Pin
User 48350471-Oct-18 3:35
User 48350471-Oct-18 3:35 
AnswerRe: Any language supports this type of syntax? PinPopular
Richard Deeming28-Sep-18 2:18
mveRichard Deeming28-Sep-18 2:18 
GeneralRe: Any language supports this type of syntax? Pin
Dominic Burford28-Sep-18 5:58
professionalDominic Burford28-Sep-18 5:58 
AnswerRe: Any language supports this type of syntax? Pin
QuantumPlumber28-Sep-18 2:25
professionalQuantumPlumber28-Sep-18 2:25 
AnswerRe: Any language supports this type of syntax? Pin
PIEBALDconsult28-Sep-18 2:59
mvePIEBALDconsult28-Sep-18 2:59 
AnswerRe: Any language supports this type of syntax? Pin
David O'Neil28-Sep-18 5:57
professionalDavid O'Neil28-Sep-18 5:57 
AnswerRe: Any language supports this type of syntax? Pin
Eddy Vluggen28-Sep-18 6:26
professionalEddy Vluggen28-Sep-18 6:26 
GeneralRe: Any language supports this type of syntax? Pin
Richard Deeming28-Sep-18 6:38
mveRichard Deeming28-Sep-18 6:38 
GeneralRe: Any language supports this type of syntax? Pin
Eddy Vluggen28-Sep-18 6:41
professionalEddy Vluggen28-Sep-18 6:41 
GeneralRe: Any language supports this type of syntax? Pin
Richard Deeming28-Sep-18 6:50
mveRichard Deeming28-Sep-18 6:50 
GeneralRe: Any language supports this type of syntax? Pin
Eddy Vluggen28-Sep-18 8:15
professionalEddy Vluggen28-Sep-18 8:15 
AnswerRe: Any language supports this type of syntax? Pin
Joan M28-Sep-18 9:16
professionalJoan M28-Sep-18 9:16 
GeneralRe: Any language supports this type of syntax? Pin
Eytukan28-Sep-18 17:38
Eytukan28-Sep-18 17:38 
AnswerRe: Any language supports this type of syntax? Pin
DaveAuld28-Sep-18 19:52
professionalDaveAuld28-Sep-18 19:52 
GeneralRe: Any language supports this type of syntax? Pin
Eytukan30-Sep-18 20:15
Eytukan30-Sep-18 20:15 
GeneralSydney Water must employ acronym freaks Pin
Peter_in_278027-Sep-18 22:23
professionalPeter_in_278027-Sep-18 22:23 

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

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   23 votes