Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation to explain new if syntax #82

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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