Thank you. This was what i were looking for.
/mikkel
On Thu, 15 Aug 2019 at 17:59, Simon Proctor wrote:
> Oh. That's easy use an any junction.
>
> say any(@objects) ~~ Bool;
>
> On Thu, 15 Aug 2019 at 16:10, Mikkel wrote:
>
>> Hi Simon
>>
>> That was certainly a simple way.
>> But this checks
Oh. That's easy use an any junction.
say any(@objects) ~~ Bool;
On Thu, 15 Aug 2019 at 16:10, Mikkel wrote:
> 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
Isn't that a smart match on a type object?
> say @objects.any ~~ Bool
True
> say @objects.any ~~ Rat
False
-y
-y
On Thu, Aug 15, 2019 at 8:11 AM Mikkel wrote:
>
> Hi Simon
>
> That was certainly a simple way.
> But this checks for the value of True rather than the object type Bool right?
>
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 wrote:
> The easiest option
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
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 t