Skip to content

Commit b9fe075

Browse files
[8.x] Fix skipWhile callback note (#7474)
If the callback given to `skipWhile` never returns `false`, then an empty collection would be returned. Currently the documentation states the opposite. If the callback never returns `true`, then the whole collection is returned unfiltered. ``` >>> $collection = collect([1, 2, 3, 4]); => Illuminate\Support\Collection {#4833 all: [ 1, 2, 3, 4, ], } >>> $subset = $collection->skipWhile(function ($item) { return false; }); => Illuminate\Support\Collection {#4835 all: [ 1, 2, 3, 4, ], } >>> $subset = $collection->skipWhile(function ($item) { return true; }); => Illuminate\Support\Collection {#4824 all: [], } ```
1 parent e8f8f31 commit b9fe075

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

collections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ The `skipWhile` method skips over items from the collection while the given call
19981998

19991999
// [4]
20002000

2001-
> {note} If the callback never returns `true`, the `skipWhile` method will return an empty collection.
2001+
> {note} If the callback never returns `false`, the `skipWhile` method will return an empty collection.
20022002
20032003
<a name="method-slice"></a>
20042004
#### `slice()` {#collection-method}

0 commit comments

Comments
 (0)