You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Runtime Environment/Table.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -168,6 +168,15 @@ t:foreach(print)
168
168
--> 2
169
169
--> 3
170
170
```
171
+
If the callback has a non-nil return, it is propagated:
172
+
```pluto
173
+
local t = { 1, 2, 3 }
174
+
print(t:foreach(function(value)
175
+
if value % 2 == 0 then
176
+
return value
177
+
end
178
+
end)) --> 2
179
+
```
171
180
---
172
181
### `table.filter`
173
182
Filters away keys (both array and non-array) that fail to meet the condition established by `callback`. Elimination is done by setting the value to `nil`, consider using `table.reorder` if you want a continuous array after filtering.
0 commit comments