From 614a1784bcc8277fbe8bb1a2d55f727c2a6eb04c Mon Sep 17 00:00:00 2001 From: algochoi <86622919+algochoi@users.noreply.github.com> Date: Mon, 26 Jul 2021 12:08:15 -0700 Subject: [PATCH] Update documentation to explain new if syntax --- docs/control_structures.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/control_structures.rst b/docs/control_structures.rst index f30bcff17..f2c943b56 100644 --- a/docs/control_structures.rst +++ b/docs/control_structures.rst @@ -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`). @@ -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`