IIF

Is possible to make Visual Cobol code shorter similar to something like that ?

string ReturnValue = Expression == true ? TruePart : FalsePart;

Using this the code would be shorter by 4 lines.

Tags:

Parents
  • Verified Answer

    We don't have any direct equivalent for this in COBOL syntax.  Of course, it's possible to do this in two lines in COBOL:

    declare ReturnValue as string

    if Expression set ReturnValue to TruePart else set ReturnValue to FalsePart end-if

    ...but probably most people would split this and use normal indentation for the sake of readability.

    I think the C# (and C) '?' syntax is probably most useful in contexts like parameter passing, and it's certainly possible we might want to add a construct like this to the language at some point.

Reply
  • Verified Answer

    We don't have any direct equivalent for this in COBOL syntax.  Of course, it's possible to do this in two lines in COBOL:

    declare ReturnValue as string

    if Expression set ReturnValue to TruePart else set ReturnValue to FalsePart end-if

    ...but probably most people would split this and use normal indentation for the sake of readability.

    I think the C# (and C) '?' syntax is probably most useful in contexts like parameter passing, and it's certainly possible we might want to add a construct like this to the language at some point.

Children
No Data