The easiest option would be use the set operators. In this case (elem) (or
∈) will coerce your array to a Set and then check to see if the given item
is in it.

my @objects = [1, True, "string", 5,];
say True (elem) @objects;
say True ∈ @objects;

Give True. Note Removing the True from the list and we get False so we
don't have to worry about the joys of truthiness it's taking your types
into account.

Hope that helps.


On Thu, 15 Aug 2019 at 15:29, Mikkel <> wrote:

> Hello.
> Suppose I have an array (or should I say a positional?):
> my @objects = [1, True, "string", 5,];
> Containing different kind of objects. It could be Ints, Strs and Bools.
> Is there a nice way of determining if for example a Bool is present in the
> array, returning True or False whether the given object is present or not?
> Best Regards
> Mikkel Birkedam

Simon Proctor
Cognoscite aliquid novum cotidie

Reply via email to