Skip to content

Commit

Permalink
Merge pull request #176 from Flipez/loop-return
Browse files Browse the repository at this point in the history
[foreach/while] Document return value
  • Loading branch information
Flipez authored Dec 19, 2022
2 parents fb87f9e + 92c46dd commit 71bb1c4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/docs/control_expressions/foreach.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ end
input = a
```

## Return Value
Loops do return the variable they are iterating after the last loop.

```js
def iterate(items)
foreach item in items
puts(item)
end
end

a = [1,2,3,4,5]

b = iterate(a)

// b is now [1,2,3,4,5]
```

## Using an integer
Count form zero to a given number (excluding):

Expand Down
17 changes: 17 additions & 0 deletions docs/docs/control_expressions/while.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,21 @@ end
4
5
6
```

## Return Value
Loops do return the variable they are iterating after the last loop.

```js
def iterate(items)
foreach item in items
puts(item)
end
end

a = [1,2,3,4,5]

b = iterate(a)

// b is now [1,2,3,4,5]
```

2 comments on commit 71bb1c4

@vercel
Copy link

@vercel vercel bot commented on 71bb1c4 Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 71bb1c4 Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.