diff --git a/README.md b/README.md index e6fbcd8..3093773 100644 --- a/README.md +++ b/README.md @@ -5211,7 +5211,7 @@ Map::from( [['p' => 30], ['p' => 50], ['p' => 10]] )->sum( 'p' ); Map::from( [['i' => ['p' => 30]], ['i' => ['p' => 50]]] )->sum( 'i/p' ); // 80 -Map::from( [30, 50, 10] )->sum( fn( $val, $key ) => $val < 50 ? $val : 0 ); +Map::from( [30, 50, 10] )->sum( fn( $val, $key ) => $val < 50 ); // 40 ``` diff --git a/tests/MapTest.php b/tests/MapTest.php index 21fd452..a19fc66 100644 --- a/tests/MapTest.php +++ b/tests/MapTest.php @@ -3122,8 +3122,8 @@ public function testSum() public function testSumClosure() { - $this->assertSame( 40.0, Map::from( [30, 50, 10] )->sum( function( $val ) { return $val < 50 ? $val : 0; } ) ); - $this->assertSame( 60.0, Map::from( [30, 50, 10] )->sum( function( $val, $key ) { return $key > 0 ? $val : 0; } ) ); + $this->assertSame( 40.0, Map::from( [30, 50, 10] )->sum( function( $val ) { return $val < 50; } ) ); + $this->assertSame( 60.0, Map::from( [30, 50, 10] )->sum( function( $val, $key ) { return $key > 0; } ) ); }