add contains? function for collections

This commit is contained in:
Pekka Laiho 2022-07-04 13:26:50 +07:00
parent adc59073a1
commit 8f4edd2106

View File

@ -72,6 +72,10 @@ class Collections implements ILib
} }
)); ));
$env->set('contains?', new CoreFunc('contains?', 'Return true if first argument (collection) contains the second argument. Use optional third argument for strict comparison.', 2, 3,
fn (Seq $a, $b, bool $strict = false) => in_array($b, $a->getData(), $strict)
));
$env->set('get', new CoreFunc('get', 'Get the item from first argument (collection) by using the second argument as index or key.', 2, 2, $env->set('get', new CoreFunc('get', 'Get the item from first argument (collection) by using the second argument as index or key.', 2, 2,
fn (Collection $a, $b) => $a->get($b) fn (Collection $a, $b) => $a->get($b)
)); ));