Skip to content

Commit

Permalink
Update documentation to explain new if syntax (algorand#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
algochoi authored Jul 26, 2021
1 parent 1610f64 commit 6675d82
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/control_structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ In an :any:`If` expression,
If(test-expr, then-expr, else-expr)
the :code:`test-expr` is always evaludated and needs to be typed :code:`TealType.uint64`.
the :code:`test-expr` is always evaluated and needs to be typed :code:`TealType.uint64`.
If it results in a value greater than `0`, then the :code:`then-expr` is evaluated.
Otherwise, :code:`else-expr` is evaluated. Note that :code:`then-expr` and :code:`else-expr` must
evaluate to the same type (e.g. both :code:`TealType.uint64`).
Expand All @@ -80,6 +80,17 @@ You may also invoke an :any:`If` expression without an :code:`else-expr`:
In this case, :code:`then-expr` must be typed :code:`TealType.none`.

There is also an alternate way to write an :any:`If` expression that makes reading
complex statements easier to read.

.. code-block:: racket
If(test-expr)
.Then(then-expr)
.ElseIf(test-expr)
.Then(then-expr)
.Else(else-expr)
.. _assert_expr:

Checking Conditions: :code:`Assert`
Expand Down

0 comments on commit 6675d82

Please sign in to comment.