Skip to content

Commit

Permalink
Minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Aug 2, 2024
1 parent 1b64f8a commit 647a201
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
4 changes: 2 additions & 2 deletions tests/MapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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; } ) );
}


Expand Down

0 comments on commit 647a201

Please sign in to comment.