Skip to content

Commit 96a6a2e

Browse files
committed
Fixed example in docs for sliding()
1 parent 9e539f2 commit 96a6a2e

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5594,14 +5594,15 @@ public function sliding( int $size = 2, int $step = 1 ) : self
55945594
**Examples:**
55955595

55965596
```php
5597-
Map::from( [1, 2, 3, 4] )->sliding( 2 );
5597+
Map::from( [1, 2, 3, 4, 5] )->sliding( 2 );
55985598
// [
55995599
// [0 => 1, 1 => 2],
56005600
// [1 => 2, 2 => 3],
5601-
// [2 => 3, 3 => 4]
5601+
// [2 => 3, 3 => 4],
5602+
// [3 => 4, 4 => 5]
56025603
// ]
56035604

5604-
Map::from( [1, 2, 3, 4] )->sliding( 3, 2 );
5605+
Map::from( [1, 2, 3, 4, 5] )->sliding( 3, 2 );
56055606
// [
56065607
// [0 => 1, 1 => 2, 2 => 3],
56075608
// [2 => 3, 3 => 4, 4 => 5]

src/Map.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4561,11 +4561,11 @@ public function slice( int $offset, ?int $length = null ) : self
45614561
* Returns a new map containing sliding windows of the original map.
45624562
*
45634563
* Examples:
4564-
* Map::from( [1, 2, 3, 4] )->sliding( 2 );
4565-
* Map::from( [1, 2, 3, 4] )->sliding( 3, 2 );
4564+
* Map::from( [1, 2, 3, 4, 5] )->sliding( 2 );
4565+
* Map::from( [1, 2, 3, 4, 5] )->sliding( 3, 2 );
45664566
*
45674567
* Results:
4568-
* The first example will return [[0 => 1, 1 => 2], [1 => 2, 2 => 3], [2 => 3, 3 => 4]]
4568+
* The first example will return [[0 => 1, 1 => 2], [1 => 2, 2 => 3], [2 => 3, 3 => 4], [3 => 4, 4 => 5]]
45694569
* while the second one will return [[0 => 1, 1 => 2, 2 => 3], [2 => 3, 3 => 4, 4 => 5]]
45704570
*
45714571
* @param int $size Size of each window

0 commit comments

Comments
 (0)