OCLOperators casetruefalse
No edit summary
Line 6: Line 6:
  endif
  endif
This operator enables you to write the same thing as
This operator enables you to write the same thing as
  somebool.TrueFalse(someexpressionwithtypeX,someOtherexpressionwithtypeX)
  somebool.casetruefalse(someexpressionwithtypeX,someOtherexpressionwithtypeX)
This makes a switch like construct look like this:
This makes a switch like construct look like this:
  let x=SomeObject.SomeEnum in
  let x=SomeObject.SomeEnum in
  (
  (
    (x=#Enum1).TrueFalse(SomeObject.DoYourThing1,DoNothing);
    (x=#Enum1).casetruefalse(SomeObject.DoYourThing1,DoNothing);
    (x=#Enum2).TrueFalse(SomeObject.DoYourThing2,DoNothing);
    (x=#Enum2).casetruefalse(SomeObject.DoYourThing2,DoNothing);
    (x=#Enum3).TrueFalse(SomeObject.DoYourThing3,DoNothing)
    (x=#Enum3).casetruefalse(SomeObject.DoYourThing3,DoNothing)
  )
  )
See also [[OCLOperators_case]]
See also [[OCLOperators_whentrue]]

Revision as of 13:37, 4 December 2021

This is a new compact form to write :

if somebool then
  someexpressionwithtypeX
else
  someOtherexpressionwithtypeX
endif

This operator enables you to write the same thing as

somebool.casetruefalse(someexpressionwithtypeX,someOtherexpressionwithtypeX)

This makes a switch like construct look like this:

let x=SomeObject.SomeEnum in
(
  (x=#Enum1).casetruefalse(SomeObject.DoYourThing1,DoNothing);
  (x=#Enum2).casetruefalse(SomeObject.DoYourThing2,DoNothing);
  (x=#Enum3).casetruefalse(SomeObject.DoYourThing3,DoNothing)
)

See also OCLOperators_whentrue

This page was edited 78 days ago on 02/10/2024. What links here