Hi Simon That was certainly a simple way. But this checks for the value of True rather than the object type Bool right? What if I wanted to know if an Int, (with any given value) were among the values?
Best regards Mikkel On Thu, 15 Aug 2019 at 16:38, Simon Proctor <simon.proc...@gmail.com> wrote: > 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, Str.new]; > 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. > > Simon > > > On Thu, 15 Aug 2019 at 15:29, Mikkel <mikkelst...@gmail.com> wrote: > >> Hello. >> >> Suppose I have an array (or should I say a positional?): >> my @objects = [1, True, "string", 5, Str.new]; >> 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 > > http://www.khanate.co.uk/ >