Skip to content
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
28 changes: 14 additions & 14 deletions content/documentation/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ have the form `:modifier argument`. The following modifiers are supported:
(for [x :range [0 4] y :range [0 x]] [x y]) # Evaluates to [[1 0] [2 0] [2 1] [3 0] [3 1] [3 2]]
```

# Do

```phel
(do expr*)
```

Evaluates the expressions in order and returns the value of the last expression. If no expression is given, `nil` is returned.

```phel
(do 1 2 3 4) # Evaluates to 4
(do (print 1) (print 2) (print 3)) # Print 1, 2, and 3
```

# Dofor

```
Expand All @@ -164,7 +177,7 @@ have the form `:modifier argument`. The following modifiers are supported:

Iterating over collections for side-effects is also possible with `dofor` which has similar behavior to `for` otherwise but returns `nil` as `foreach` does.

## Exceptions
# Exceptions

```phel
(throw expr)
Expand Down Expand Up @@ -196,16 +209,3 @@ All expressions are evaluated and if no exception is thrown the value of the las
(catch \Exception e "error")
(finally (print "test"))) # Evaluates to "error" and prints "test"
```

## Statements (do)

```phel
(do expr*)
```

Evaluates the expressions in order and returns the value of the last expression. If no expression is given, `nil` is returned.

```phel
(do 1 2 3 4) # Evaluates to 4
(do (print 1) (print 2) (print 3)) # Print 1, 2, and 3
```
Loading