3.1 Implementing conditional - rayhan-ferdous/ProvMod GitHub Wiki
From the example of Section 2.1 you can just embed a condition while you run a module.
d_out1, d_out2 = m.run(when = (len(d_in.ref) < 6), false_return = (None, 0))
This example will set d_out1
to None
and d_out2
to 0
, but not any Data inherited type (it's up to you actually).
print x, y
The parameter when
is a boolean expression and false_return
is the result your module generates when the expression is False
.
By default when = True
and false_return = None
. Here, we are giving freedom to the developer for setting the output flow when the condition is False.
We have to do it explicitly, because we do not know in advance how many output will be generated during the body overriding.