convert symbol to string

This commit is contained in:
Pekka Laiho 2020-06-04 09:15:40 +07:00
parent 437bf252c5
commit b568ece8f0

View File

@ -29,7 +29,7 @@ class Types implements ILib
));
$env->set('str', new CoreFunc('str', 'Convert arguments to string and concatenate them together.', 0, -1,
fn (...$args) => implode('', array_map('strval', $args))
fn (...$args) => implode('', array_map([$this, 'getStrValue'], $args))
));
$env->set('symbol', new CoreFunc('symbol', 'Convert argument to symbol.', 1, 1,
@ -134,4 +134,13 @@ class Types implements ILib
fn ($a) => $a % 2 !== 0
));
}
private function getStrValue($a)
{
if ($a instanceof Symbol) {
return $a->getName();
}
return strval($a);
}
}