diff --git a/doc/procedures/if.md b/doc/procedures/if.md index 06dd041e..3f53b30f 100644 --- a/doc/procedures/if.md +++ b/doc/procedures/if.md @@ -42,6 +42,27 @@ if Currently, if an "else if" is needed, it's better to use [cond](cond.md). +## improving readability with else and then + +"then" and "else" can be aliased to "sequence" and be used within if to +make the flow definition easier to read, and especially less confusing. + +``` +# at the top of the workflow definition +# alias "then" and "else" to "sequence" + +set then sequence +set else sequence + +# ... + +if (f.age > 3) + then + set f.designation 'child' + else + set f.designation 'baby' + order_baby_food _ +``` ## see also diff --git a/lib/flor/pcore/if.rb b/lib/flor/pcore/if.rb index b8eccd10..cb2e7eda 100644 --- a/lib/flor/pcore/if.rb +++ b/lib/flor/pcore/if.rb @@ -43,6 +43,27 @@ class Flor::Pro::If < Flor::Procedure # # Currently, if an "else if" is needed, it's better to use [cond](cond.md). # + # ## improving readability with else and then + # + # "then" and "else" can be aliased to "sequence" and be used within if to + # make the flow definition easier to read, and especially less confusing. + # + # ``` + # # at the top of the workflow definition + # # alias "then" and "else" to "sequence" + # + # set then sequence + # set else sequence + # + # # ... + # + # if (f.age > 3) + # then + # set f.designation 'child' + # else + # set f.designation 'baby' + # order_baby_food _ + # ``` # # ## see also #