Getting started with Flow.apex
Return Statement
returnXxx in Flow.apex only specifies what type of result is returned. To actually return something, call doReturn(Object) or doReturnRaw(Object).
Flow f = new Flow()
.inputAs('a', 'b').returnInteger()
.doReturn(0);If no doReturn or equivalent is added, the Flow Func will return null.
The difference between doReturn and doReturnRaw is that doReturn treats String as FlowScript while doReturnRaw does not.
Flow f = new Flow()
.inputAs('a', 'b').returnInteger()
.doReturn('"message"');is equivalent to
Flow f = new Flow()
.inputAs('a', 'b').returnInteger()
.doReturnRaw('message');