mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-11-30 04:39:48 +01:00
simplify the readme example (#21)
This commit is contained in:
parent
7bf9aefe17
commit
723a4f208e
@ -28,9 +28,12 @@ use Psl\Iter;
|
|||||||
*/
|
*/
|
||||||
function foo(iterable $codes): string
|
function foo(iterable $codes): string
|
||||||
{
|
{
|
||||||
return Str\join(Iter\map(
|
/** @var Iter\Iterator<int> $codes */
|
||||||
Iter\filter_nulls($codes), fn($i) => Str\chr($i),
|
$codes = Iter\filter_nulls($codes);
|
||||||
), ', ');
|
/** @var Iter\Iterator<string> $chars */
|
||||||
|
$chars = Iter\map($codes, fn(int $code): string => Str\chr($code));
|
||||||
|
|
||||||
|
return Str\join($chars, ', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
foo([95, 96, null, 98]);
|
foo([95, 96, null, 98]);
|
||||||
|
Loading…
Reference in New Issue
Block a user