Getting started with Flow.apex
If Block
Flow.apex supports if
and if not
blocks.
Flow f = new Flow()
.inputAs('a', 'b').returnInteger()
.doIf(
'a == 1',
Flow.block().doReturn(1)
);
And we can append the else
block too.
Flow f = new Flow()
.inputAs('a', 'b').returnInteger()
.doIf(
'a == 1',
Flow.block().doReturn(1),
Flow.block().doReturn(2)
);
Here if
needs at least one block. A block in Flow.apex is actually a block of executable statements. We can use the blocks to extend our logic.
Flow f = new Flow()
.inputAs('a', 'b').returnInteger()
.doIf(
'a == 1',
Flow.block()
.var('b = 2')
// more logic goes on here
.doReturn(1)
);