Forum Discussion
IF with multiple statements in M language
Hi Anonymous ,
you can compare the let-in-construct with a Begin-End-syntax like you've described.
Just have in mind that PQ is lazy, so it will only evaluate/execute steps that are necessary to evaluate the "in"-result.
So if every step shall be a single execution of something (which I'm having difficulties to imagine, but your question is fairly generic, so I'm not questioning that), then make sure that its result (or a reference to it) is referenced by the final result.
In the following valid M-code the "statement3" will not be executed, because it is not needed to evaluate the final result:
if 1 = 1 // Condition
then
let // Begin
Statement1 = 10,
Statement2 = 20,
Statement3 = 40
in
Statement1 + Statement2 // End
else
0
If your statements shall do something more interesting like calling APIs for example, make sure that you reference their results somehow in what the "in" returns.