simplify the readme example (#21)

This commit is contained in:
Saif Eddin G 2020-07-06 22:45:13 +02:00 committed by GitHub
parent 7bf9aefe17
commit 723a4f208e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,9 +28,12 @@ use Psl\Iter;
*/
function foo(iterable $codes): string
{
return Str\join(Iter\map(
Iter\filter_nulls($codes), fn($i) => Str\chr($i),
), ', ');
/** @var Iter\Iterator<int> $codes */
$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]);