Skip to content

Commit

Permalink
Document aliasing "then" and "else" to "sequence"
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Jan 7, 2024
1 parent 40f23fe commit e5f05f5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions doc/procedures/if.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 21 additions & 0 deletions lib/flor/pcore/if.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down

0 comments on commit e5f05f5

Please sign in to comment.